/*
 * Test images, functions and values used across the surface, texture and
 * volume test files.
 *
 * Copyright 2024 Connor McAdams for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <stdint.h>
#include <assert.h>
#define COBJMACROS
#include "d3dx9tex.h"

/*
 * MAKE_DDHRESULT is first defined in d3dx9.h, with the same definition as the
 * one in ddraw.h.
 */
#ifdef MAKE_DDHRESULT
#undef MAKE_DDHRESULT
#endif
#include "ddraw.h"

/* dds_pixel_format.flags */
#define DDS_PF_ALPHA 0x00000001
#define DDS_PF_ALPHA_ONLY 0x00000002
#define DDS_PF_FOURCC 0x00000004
#define DDS_PF_INDEXED 0x00000020
#define DDS_PF_RGB 0x00000040
#define DDS_PF_LUMINANCE 0x00020000
#define DDS_PF_BUMPLUMINANCE 0x00040000
#define DDS_PF_BUMPDUDV 0x00080000

struct dds_pixel_format
{
    DWORD size;
    DWORD flags;
    DWORD fourcc;
    DWORD bpp;
    DWORD rmask;
    DWORD gmask;
    DWORD bmask;
    DWORD amask;
};

struct dds_header
{
    DWORD size;
    DWORD flags;
    DWORD height;
    DWORD width;
    DWORD pitch_or_linear_size;
    DWORD depth;
    DWORD miplevels;
    DWORD reserved[11];
    struct dds_pixel_format pixel_format;
    DWORD caps;
    DWORD caps2;
    DWORD caps3;
    DWORD caps4;
    DWORD reserved2;
};

#define DDS_FILE_HEADER_SIZE (sizeof(uint32_t) + sizeof(struct dds_header))
#define PALETTED_DDS_FILE_HEADER_SIZE (DDS_FILE_HEADER_SIZE + (sizeof(PALETTEENTRY) * 256))

static const struct
{
    uint32_t filter;
    HRESULT expected_hr;
}
test_filter_values[] =
{
    { D3DX_DEFAULT,         D3D_OK },
    /* Any combo of MIRROR/DITHER/SRGB bits are valid. */
    { 0x007f0001,           D3D_OK },
    { D3DX_DEFAULT_NONPOW2, D3DERR_INVALIDCALL },
    { D3DX_FROM_FILE,       D3DERR_INVALIDCALL },
    { 0,                    D3DERR_INVALIDCALL },
    { D3DX_FILTER_BOX + 1,  D3DERR_INVALIDCALL },
    { 0x0000ffff,           D3DERR_INVALIDCALL },
    /* Any unused filter bits being set results in failure. */
    { 0xff800001,           D3DERR_INVALIDCALL },
};

static const PALETTEENTRY test_palette[256] =
{
    {0x00,0x00,0x00,0x00}, {0x00,0x00,0x80,0x01}, {0x00,0x80,0x00,0x02}, {0x00,0x80,0x80,0x03},
    {0x80,0x00,0x00,0x04}, {0x80,0x00,0x80,0x05}, {0x80,0x80,0x00,0x06}, {0xc0,0xc0,0xc0,0x07},
    {0xc0,0xdc,0xc0,0x08}, {0xf0,0xca,0xa6,0x09}, {0x00,0x20,0x40,0x0a}, {0x00,0x20,0x60,0x0b},
    {0x00,0x20,0x80,0x0c}, {0x00,0x20,0xa0,0x0d}, {0x00,0x20,0xc0,0x0e}, {0x00,0x20,0xe0,0x0f},

    {0x00,0x40,0x00,0x10}, {0x00,0x40,0x20,0x11}, {0x00,0x40,0x40,0x12}, {0x00,0x40,0x60,0x13},
    {0x00,0x40,0x80,0x14}, {0x00,0x40,0xa0,0x15}, {0x00,0x40,0xc0,0x16}, {0x00,0x40,0xe0,0x17},
    {0x00,0x60,0x00,0x18}, {0x00,0x60,0x20,0x19}, {0x00,0x60,0x40,0x1a}, {0x00,0x60,0x60,0x1b},
    {0x00,0x60,0x80,0x1c}, {0x00,0x60,0xa0,0x1d}, {0x00,0x60,0xc0,0x1e}, {0x00,0x60,0xe0,0x1f},

    {0x00,0x80,0x00,0x20}, {0x00,0x80,0x20,0x21}, {0x00,0x80,0x40,0x22}, {0x00,0x80,0x60,0x23},
    {0x00,0x80,0x80,0x24}, {0x00,0x80,0xa0,0x25}, {0x00,0x80,0xc0,0x26}, {0x00,0x80,0xe0,0x27},
    {0x00,0xa0,0x00,0x28}, {0x00,0xa0,0x20,0x29}, {0x00,0xa0,0x40,0x2a}, {0x00,0xa0,0x60,0x2b},
    {0x00,0xa0,0x80,0x2c}, {0x00,0xa0,0xa0,0x2d}, {0x00,0xa0,0xc0,0x2e}, {0x00,0xa0,0xe0,0x2f},

    {0x00,0xc0,0x00,0x30}, {0x00,0xc0,0x20,0x31}, {0x00,0xc0,0x40,0x32}, {0x00,0xc0,0x60,0x33},
    {0x00,0xc0,0x80,0x34}, {0x00,0xc0,0xa0,0x35}, {0x00,0xc0,0xc0,0x36}, {0x00,0xc0,0xe0,0x37},
    {0x00,0xe0,0x00,0x38}, {0x00,0xe0,0x20,0x39}, {0x00,0xe0,0x40,0x3a}, {0x00,0xe0,0x60,0x3b},
    {0x00,0xe0,0x80,0x3c}, {0x00,0xe0,0xa0,0x3d}, {0x00,0xe0,0xc0,0x3e}, {0x00,0xe0,0xe0,0x3f},

    {0x40,0x00,0x00,0x40}, {0x40,0x00,0x20,0x41}, {0x40,0x00,0x40,0x42}, {0x40,0x00,0x60,0x43},
    {0x40,0x00,0x80,0x44}, {0x40,0x00,0xa0,0x45}, {0x40,0x00,0xc0,0x46}, {0x40,0x00,0xe0,0x47},
    {0x40,0x20,0x00,0x48}, {0x40,0x20,0x20,0x49}, {0x40,0x20,0x40,0x4a}, {0x40,0x20,0x60,0x4b},
    {0x40,0x20,0x80,0x4c}, {0x40,0x20,0xa0,0x4d}, {0x40,0x20,0xc0,0x4e}, {0x40,0x20,0xe0,0x4f},

    {0x40,0x40,0x00,0x50}, {0x40,0x40,0x20,0x51}, {0x40,0x40,0x40,0x52}, {0x40,0x40,0x60,0x53},
    {0x40,0x40,0x80,0x54}, {0x40,0x40,0xa0,0x55}, {0x40,0x40,0xc0,0x56}, {0x40,0x40,0xe0,0x57},
    {0x40,0x60,0x00,0x58}, {0x40,0x60,0x20,0x59}, {0x40,0x60,0x40,0x5a}, {0x40,0x60,0x60,0x5b},
    {0x40,0x60,0x80,0x5c}, {0x40,0x60,0xa0,0x5d}, {0x40,0x60,0xc0,0x5e}, {0x40,0x60,0xe0,0x5f},

    {0x40,0x80,0x00,0x60}, {0x40,0x80,0x20,0x61}, {0x40,0x80,0x40,0x62}, {0x40,0x80,0x60,0x63},
    {0x40,0x80,0x80,0x64}, {0x40,0x80,0xa0,0x65}, {0x40,0x80,0xc0,0x66}, {0x40,0x80,0xe0,0x67},
    {0x40,0xa0,0x00,0x68}, {0x40,0xa0,0x20,0x69}, {0x40,0xa0,0x40,0x6a}, {0x40,0xa0,0x60,0x6b},
    {0x40,0xa0,0x80,0x6c}, {0x40,0xa0,0xa0,0x6d}, {0x40,0xa0,0xc0,0x6e}, {0x40,0xa0,0xe0,0x6f},

    {0x40,0xc0,0x00,0x70}, {0x40,0xc0,0x20,0x71}, {0x40,0xc0,0x40,0x72}, {0x40,0xc0,0x60,0x73},
    {0x40,0xc0,0x80,0x74}, {0x40,0xc0,0xa0,0x75}, {0x40,0xc0,0xc0,0x76}, {0x40,0xc0,0xe0,0x77},
    {0x40,0xe0,0x00,0x78}, {0x40,0xe0,0x20,0x79}, {0x40,0xe0,0x40,0x7a}, {0x40,0xe0,0x60,0x7b},
    {0x40,0xe0,0x80,0x7c}, {0x40,0xe0,0xa0,0x7d}, {0x40,0xe0,0xc0,0x7e}, {0x40,0xe0,0xe0,0x7f},

    {0x80,0x00,0x00,0x80}, {0x80,0x00,0x20,0x81}, {0x80,0x00,0x40,0x82}, {0x80,0x00,0x60,0x83},
    {0x80,0x00,0x80,0x84}, {0x80,0x00,0xa0,0x85}, {0x80,0x00,0xc0,0x86}, {0x80,0x00,0xe0,0x87},
    {0x80,0x20,0x00,0x88}, {0x80,0x20,0x20,0x89}, {0x80,0x20,0x40,0x8a}, {0x80,0x20,0x60,0x8b},
    {0x80,0x20,0x80,0x8c}, {0x80,0x20,0xa0,0x8d}, {0x80,0x20,0xc0,0x8e}, {0x80,0x20,0xe0,0x8f},

    {0x80,0x40,0x00,0x90}, {0x80,0x40,0x20,0x91}, {0x80,0x40,0x40,0x92}, {0x80,0x40,0x60,0x93},
    {0x80,0x40,0x80,0x94}, {0x80,0x40,0xa0,0x95}, {0x80,0x40,0xc0,0x96}, {0x80,0x40,0xe0,0x97},
    {0x80,0x60,0x00,0x98}, {0x80,0x60,0x20,0x99}, {0x80,0x60,0x40,0x9a}, {0x80,0x60,0x60,0x9b},
    {0x80,0x60,0x80,0x9c}, {0x80,0x60,0xa0,0x9d}, {0x80,0x60,0xc0,0x9e}, {0x80,0x60,0xe0,0x9f},

    {0x80,0x80,0x00,0xa0}, {0x80,0x80,0x20,0xa1}, {0x80,0x80,0x40,0xa2}, {0x80,0x80,0x60,0xa3},
    {0x80,0x80,0x80,0xa4}, {0x80,0x80,0xa0,0xa5}, {0x80,0x80,0xc0,0xa6}, {0x80,0x80,0xe0,0xa7},
    {0x80,0xa0,0x00,0xa8}, {0x80,0xa0,0x20,0xa9}, {0x80,0xa0,0x40,0xaa}, {0x80,0xa0,0x60,0xab},
    {0x80,0xa0,0x80,0xac}, {0x80,0xa0,0xa0,0xad}, {0x80,0xa0,0xc0,0xae}, {0x80,0xa0,0xe0,0xaf},

    {0x80,0xc0,0x00,0xb0}, {0x80,0xc0,0x20,0xb1}, {0x80,0xc0,0x40,0xb2}, {0x80,0xc0,0x60,0xb3},
    {0x80,0xc0,0x80,0xb4}, {0x80,0xc0,0xa0,0xb5}, {0x80,0xc0,0xc0,0xb6}, {0x80,0xc0,0xe0,0xb7},
    {0x80,0xe0,0x00,0xb8}, {0x80,0xe0,0x20,0xb9}, {0x80,0xe0,0x40,0xba}, {0x80,0xe0,0x60,0xbb},
    {0x80,0xe0,0x80,0xbc}, {0x80,0xe0,0xa0,0xbd}, {0x80,0xe0,0xc0,0xbe}, {0x80,0xe0,0xe0,0xbf},

    {0xc0,0x00,0x00,0xc0}, {0xc0,0x00,0x20,0xc1}, {0xc0,0x00,0x40,0xc2}, {0xc0,0x00,0x60,0xc3},
    {0xc0,0x00,0x80,0xc4}, {0xc0,0x00,0xa0,0xc5}, {0xc0,0x00,0xc0,0xc6}, {0xc0,0x00,0xe0,0xc7},
    {0xc0,0x20,0x00,0xc8}, {0xc0,0x20,0x20,0xc9}, {0xc0,0x20,0x40,0xca}, {0xc0,0x20,0x60,0xcb},
    {0xc0,0x20,0x80,0xcc}, {0xc0,0x20,0xa0,0xcd}, {0xc0,0x20,0xc0,0xce}, {0xc0,0x20,0xe0,0xcf},

    {0xc0,0x40,0x00,0xd0}, {0xc0,0x40,0x20,0xd1}, {0xc0,0x40,0x40,0xd2}, {0xc0,0x40,0x60,0xd3},
    {0xc0,0x40,0x80,0xd4}, {0xc0,0x40,0xa0,0xd5}, {0xc0,0x40,0xc0,0xd6}, {0xc0,0x40,0xe0,0xd7},
    {0xc0,0x60,0x00,0xd8}, {0xc0,0x60,0x20,0xd9}, {0xc0,0x60,0x40,0xda}, {0xc0,0x60,0x60,0xdb},
    {0xc0,0x60,0x80,0xdc}, {0xc0,0x60,0xa0,0xdd}, {0xc0,0x60,0xc0,0xde}, {0xc0,0x60,0xe0,0xdf},

    {0xc0,0x80,0x00,0xe0}, {0xc0,0x80,0x20,0xe1}, {0xc0,0x80,0x40,0xe2}, {0xc0,0x80,0x60,0xe3},
    {0xc0,0x80,0x80,0xe4}, {0xc0,0x80,0xa0,0xe5}, {0xc0,0x80,0xc0,0xe6}, {0xc0,0x80,0xe0,0xe7},
    {0xc0,0xa0,0x00,0xe8}, {0xc0,0xa0,0x20,0xe9}, {0xc0,0xa0,0x40,0xea}, {0xc0,0xa0,0x60,0xeb},
    {0xc0,0xa0,0x80,0xec}, {0xc0,0xa0,0xa0,0xed}, {0xc0,0xa0,0xc0,0xee}, {0xc0,0xa0,0xe0,0xef},

    {0xc0,0xc0,0x00,0xf0}, {0xc0,0xc0,0x20,0xf1}, {0xc0,0xc0,0x40,0xf2}, {0xc0,0xc0,0x60,0xf3},
    {0xc0,0xc0,0x80,0xf4}, {0xc0,0xc0,0xa0,0xf5}, {0xf0,0xfb,0xff,0xf6}, {0xa4,0xa0,0xa0,0xf7},
    {0x80,0x80,0x80,0xf8}, {0x00,0x00,0xff,0xf9}, {0x00,0xff,0x00,0xfa}, {0x00,0xff,0xff,0xfb},
    {0xff,0x00,0x00,0xfc}, {0xff,0x00,0xff,0xfd}, {0xff,0xff,0x00,0xfe}, {0xff,0xff,0xff,0xff},
};

/* 1x1 bmp (1 bpp) */
static const uint8_t bmp_1bpp[] =
{
    0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
    0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
    0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
    0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00,
    0x00,0x00
};

/* 1x1 bmp (2 bpp) */
static const uint8_t bmp_2bpp[] =
{
    0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
    0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x00,0x00,
    0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
    0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00,
    0x00,0x00
};

/* 1x1 bmp (4 bpp) */
static const uint8_t bmp_4bpp[] =
{
    0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
    0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,
    0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
    0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00,
    0x00,0x00
};

/* 1x1 bmp (8 bpp) */
static const uint8_t bmp_8bpp[] =
{
    0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
    0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00,
    0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
    0x00,0x00,0x02,0x00,0x00,0x00,0xf1,0xf2,0xf3,0x80,0xf4,0xf5,0xf6,0x81,0x00,0x00,
    0x00,0x00
};

/* 2x2 bmp (32 bpp XRGB) */
static const uint8_t bmp_32bpp_xrgb[] =
{
    0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,
    0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00,
    0x00,0x00,0x10,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb0,0xc0,0x00,0xa1,0xb1,0xc1,0x00,0xa2,0xb2,
    0xc2,0x00,0xa3,0xb3,0xc3,0x00
};

/* 2x2 bmp (32 bpp ARGB) */
static const uint8_t bmp_32bpp_argb[] =
{
    0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,
    0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00,
    0x00,0x00,0x10,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb0,0xc0,0x00,0xa1,0xb1,0xc1,0x00,0xa2,0xb2,
    0xc2,0x00,0xa3,0xb3,0xc3,0x01
};

/*
 * 4x4 bmp (32 bpp ARGB) four 2x2 blocks:
 * +-----+-----+
 * |Red  |Green|
 * |     |     |
 * +-----+-----+
 * |Blue |Black|
 * |     |     |
 * +-----+-----+
 */
static const uint8_t bmp_32bpp_4_4_argb[] =
{
    0x42,0x4d,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,
    0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00,
    0x00,0x00,0x40,0x00,0x00,0x00,0x24,0x16,0x00,0x00,0x24,0x16,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0x00,0x00,
    0x00,0xff,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0x00,0x00,
    0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0xff,
    0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0xff,
    0x00,0xff,0x00,0xff,0x00,0xff,
};

static const uint8_t png_grayscale[] =
{
    0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
    0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x3a,0x7e,0x9b,
    0x55,0x00,0x00,0x00,0x0a,0x49,0x44,0x41,0x54,0x08,0xd7,0x63,0xf8,0x0f,0x00,0x01,
    0x01,0x01,0x00,0x1b,0xb6,0xee,0x56,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,
    0x42,0x60,0x82
};

static const uint8_t png_2_2_24bpp_bgr[] =
{
    0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
    0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x08,0x02,0x00,0x00,0x00,0xfd,0xd4,0x9a,
    0x73,0x00,0x00,0x00,0x16,0x49,0x44,0x41,0x54,0x08,0x99,0x63,0x54,0x10,0x60,0x30,
    0x30,0x30,0x60,0x49,0x48,0x48,0x30,0x30,0x30,0x00,0x00,0x0e,0x68,0x02,0x76,0xd0,
    0x18,0x48,0x79,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
};

static const uint8_t png_2_2_48bpp_rgb[] =
{
    0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
    0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x10,0x02,0x00,0x00,0x00,0xad,0x44,0x46,
    0x30,0x00,0x00,0x00,0x1d,0x49,0x44,0x41,0x54,0x08,0x99,0x63,0x64,0x60,0x10,0x10,
    0x50,0x50,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0x49,0x48,0x48,0x48,0x48,0x48,0x80,
    0x70,0x00,0x34,0x38,0x04,0xe6,0xd6,0xb5,0xab,0x37,0x00,0x00,0x00,0x00,0x49,0x45,
    0x4e,0x44,0xae,0x42,0x60,0x82,
};

static const uint8_t png_2_2_64bpp_rgba[] =
{
    0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
    0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x10,0x06,0x00,0x00,0x00,0x22,0x26,0xd1,
    0x67,0x00,0x00,0x00,0x26,0x49,0x44,0x41,0x54,0x08,0x99,0x63,0x64,0x60,0x10,0x10,
    0x50,0x50,0x30,0x30,0x70,0x80,0x02,0x86,0x86,0x86,0x09,0x13,0x16,0x2c,0xd8,0xb0,
    0xe1,0xc0,0x81,0x0b,0x17,0x1e,0x3c,0xf8,0xf0,0x01,0x00,0x97,0x64,0x0e,0x42,0xcc,
    0x1c,0xbb,0xb8,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
};

static const uint8_t png_2_2_1bpp_indexed[] =
{
    0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
    0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x01,0x03,0x00,0x00,0x00,0x48,0x78,0x9f,
    0x67,0x00,0x00,0x00,0x06,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0xff,0xff,0xff,0xa5,
    0xd9,0x9f,0xdd,0x00,0x00,0x00,0x01,0x74,0x52,0x4e,0x53,0x00,0x40,0xe6,0xd8,0x66,
    0x00,0x00,0x00,0x0c,0x49,0x44,0x41,0x54,0x08,0x99,0x63,0x68,0x60,0x70,0x00,0x00,
    0x01,0xc4,0x00,0xc1,0xcd,0x7b,0x18,0xa0,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,
    0xae,0x42,0x60,0x82,
};

static const uint8_t png_2_2_2bpp_indexed[] =
{
    0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
    0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x02,0x03,0x00,0x00,0x00,0x0f,0xd8,0xe5,
    0xb7,0x00,0x00,0x00,0x01,0x73,0x52,0x47,0x42,0x00,0xae,0xce,0x1c,0xe9,0x00,0x00,
    0x00,0x04,0x67,0x41,0x4d,0x41,0x00,0x00,0xb1,0x8f,0x0b,0xfc,0x61,0x05,0x00,0x00,
    0x00,0x0c,0x50,0x4c,0x54,0x45,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0xff,
    0xff,0xff,0xfb,0x00,0x60,0xf6,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,0x54,0x18,0xd3,
    0x63,0x90,0x66,0xd8,0x0d,0x00,0x01,0x10,0x00,0xd7,0xa8,0x4b,0x7a,0x58,0x00,0x00,
    0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
};

static const uint8_t png_2_2_4bpp_indexed[] =
{
    0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
    0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x04,0x03,0x00,0x00,0x00,0x80,0x98,0x10,
    0x17,0x00,0x00,0x00,0x30,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x11,0x11,0x11,0x22,
    0x22,0x22,0x33,0x33,0x33,0x44,0x44,0x44,0x55,0x55,0x55,0x66,0x66,0x66,0x77,0x77,
    0x77,0x88,0x88,0x88,0x99,0x99,0x99,0xaa,0xaa,0xaa,0xbb,0xbb,0xbb,0xcc,0xcc,0xcc,
    0xdd,0xdd,0xdd,0xee,0xee,0xee,0xff,0xff,0xff,0x7b,0x10,0x18,0x0a,0x00,0x00,0x00,
    0x10,0x74,0x52,0x4e,0x53,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
    0xf0,0xf0,0xf0,0xf0,0xf0,0xb1,0x0f,0x99,0x6f,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
    0x54,0x08,0x99,0x63,0x60,0x61,0xe8,0x01,0x00,0x00,0x9c,0x00,0x91,0x1c,0x0a,0x18,
    0x41,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
};

static const uint8_t jpg_rgb_2_2[] =
{
    0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x00,0x00,0x01,
    0x00,0x01,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x08,0x06,0x06,0x07,0x06,0x05,0x08,
    0x07,0x07,0x07,0x09,0x09,0x08,0x0a,0x0c,0x14,0x0d,0x0c,0x0b,0x0b,0x0c,0x19,0x12,
    0x13,0x0f,0x14,0x1d,0x1a,0x1f,0x1e,0x1d,0x1a,0x1c,0x1c,0x20,0x24,0x2e,0x27,0x20,
    0x22,0x2c,0x23,0x1c,0x1c,0x28,0x37,0x29,0x2c,0x30,0x31,0x34,0x34,0x34,0x1f,0x27,
    0x39,0x3d,0x38,0x32,0x3c,0x2e,0x33,0x34,0x32,0xff,0xdb,0x00,0x43,0x01,0x08,0x09,
    0x09,0x0c,0x0b,0x0c,0x18,0x0d,0x0d,0x18,0x32,0x21,0x1c,0x21,0x32,0x32,0x32,0x32,
    0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,
    0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,
    0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0xff,0xc0,
    0x00,0x11,0x08,0x00,0x02,0x00,0x02,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11,
    0x01,0xff,0xc4,0x00,0x1f,0x00,0x00,0x01,0x05,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
    0x0a,0x0b,0xff,0xc4,0x00,0xb5,0x10,0x00,0x02,0x01,0x03,0x03,0x02,0x04,0x03,0x05,
    0x05,0x04,0x04,0x00,0x00,0x01,0x7d,0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,
    0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,0x23,
    0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,
    0x18,0x19,0x1a,0x25,0x26,0x27,0x28,0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,
    0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,
    0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,
    0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,
    0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,
    0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,
    0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,
    0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xff,0xc4,0x00,0x1f,0x01,0x00,0x03,
    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
    0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,0xc4,0x00,0xb5,0x11,0x00,
    0x02,0x01,0x02,0x04,0x04,0x03,0x04,0x07,0x05,0x04,0x04,0x00,0x01,0x02,0x77,0x00,
    0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,
    0x22,0x32,0x81,0x08,0x14,0x42,0x91,0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,
    0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,0x27,
    0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,
    0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,
    0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,0x88,
    0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,
    0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,
    0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe2,
    0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,
    0xfa,0xff,0xda,0x00,0x0c,0x03,0x01,0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb7,
    0x69,0xa4,0xe9,0xbf,0x62,0x83,0xfe,0x25,0xf6,0x9f,0xea,0xd7,0xfe,0x58,0xaf,0xa7,
    0xd2,0x8a,0x28,0xae,0xb3,0x98,0xff,0xd9,
};

static const uint8_t jpg_grayscale_2_2[] =
{
    0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x00,0x00,0x01,
    0x00,0x01,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x08,0x06,0x06,0x07,0x06,0x05,0x08,
    0x07,0x07,0x07,0x09,0x09,0x08,0x0a,0x0c,0x14,0x0d,0x0c,0x0b,0x0b,0x0c,0x19,0x12,
    0x13,0x0f,0x14,0x1d,0x1a,0x1f,0x1e,0x1d,0x1a,0x1c,0x1c,0x20,0x24,0x2e,0x27,0x20,
    0x22,0x2c,0x23,0x1c,0x1c,0x28,0x37,0x29,0x2c,0x30,0x31,0x34,0x34,0x34,0x1f,0x27,
    0x39,0x3d,0x38,0x32,0x3c,0x2e,0x33,0x34,0x32,0xff,0xc0,0x00,0x0b,0x08,0x00,0x02,
    0x00,0x02,0x01,0x01,0x11,0x00,0xff,0xc4,0x00,0x1f,0x00,0x00,0x01,0x05,0x01,0x01,
    0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,
    0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,0xc4,0x00,0xb5,0x10,0x00,0x02,0x01,0x03,
    0x03,0x02,0x04,0x03,0x05,0x05,0x04,0x04,0x00,0x00,0x01,0x7d,0x01,0x02,0x03,0x00,
    0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,
    0x81,0x91,0xa1,0x08,0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,
    0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,0x29,0x2a,0x34,0x35,
    0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,
    0x56,0x57,0x58,0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,
    0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x92,0x93,0x94,
    0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,
    0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,
    0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,
    0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xff,0xda,
    0x00,0x08,0x01,0x01,0x00,0x00,0x3f,0x00,0xea,0x2c,0x34,0x1d,0x1f,0xfb,0x3a,0xdb,
    0xfe,0x25,0x36,0x3f,0xea,0x93,0xfe,0x5d,0xd3,0xd0,0x7b,0x57,0xff,0xd9,
};

/* 2x2 A8R8G8B8 pixel data */
static const uint8_t pixdata[] =
{
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};

/* invalid image file */
static const uint8_t noimage[4] =
{
    0x11,0x22,0x33,0x44
};

/* 16x4 8-bit dds  */
static const uint8_t dds_8bit[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00,
    0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
    0x47,0x49,0x4d,0x50,0x2d,0x44,0x44,0x53,0x5a,0x09,0x03,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,
    0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0xec,0x27,0x00,0xff,0x8c,0xcd,0x12,0xff,
    0x78,0x01,0x14,0xff,0x50,0xcd,0x12,0xff,0x00,0x3d,0x8c,0xff,0x02,0x00,0x00,0xff,
    0x47,0x00,0x00,0xff,0xda,0x07,0x02,0xff,0x50,0xce,0x12,0xff,0xea,0x11,0x01,0xff,
    0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x08,0x3d,0x8c,0xff,0x08,0x01,0x00,0xff,
    0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x60,0xcc,0x12,0xff,
    0xa1,0xb2,0xd4,0xff,0xda,0x07,0x02,0xff,0x47,0x00,0x00,0xff,0x00,0x00,0x00,0xff,
    0x50,0xce,0x12,0xff,0x00,0x00,0x14,0xff,0xa8,0xcc,0x12,0xff,0x3c,0xb2,0xd4,0xff,
    0xda,0x07,0x02,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x01,0xff,
    0x21,0x00,0x00,0xff,0xd8,0xcb,0x12,0xff,0x54,0xcd,0x12,0xff,0x8b,0x4f,0xd5,0xff,
    0x00,0x04,0xda,0xff,0x00,0x00,0x00,0xff,0x3d,0x04,0x91,0xff,0x70,0xce,0x18,0xff,
    0xb4,0xcc,0x12,0xff,0x6b,0x4e,0xd5,0xff,0xb0,0xcc,0x12,0xff,0x00,0x00,0x00,0xff,
    0xc8,0x05,0x91,0xff,0x98,0xc7,0xcc,0xff,0x7c,0xcd,0x12,0xff,0x51,0x05,0x91,0xff,
    0x48,0x07,0x14,0xff,0x6d,0x05,0x91,0xff,0x00,0x07,0xda,0xff,0xa0,0xc7,0xcc,0xff,
    0x00,0x07,0xda,0xff,0x3a,0x77,0xd5,0xff,0xda,0x07,0x02,0xff,0x7c,0x94,0xd4,0xff,
    0xe0,0xce,0xd6,0xff,0x0a,0x80,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,
    0x78,0x9a,0xab,0xff,0xde,0x08,0x18,0xff,0xda,0x07,0x02,0xff,0x30,0x00,0x00,0xff,
    0x00,0x00,0x00,0xff,0x50,0xce,0x12,0xff,0x8c,0xcd,0x12,0xff,0xd0,0xb7,0xd8,0xff,
    0x00,0x00,0x00,0xff,0x60,0x32,0xd9,0xff,0x30,0xc1,0x1a,0xff,0xa8,0xcd,0x12,0xff,
    0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff,0x46,0x71,0x0e,0xff,0xc0,0x1d,0x4b,0xff,
    0x09,0x87,0xd4,0xff,0x00,0x00,0x00,0xff,0xf6,0x22,0x00,0xff,0x64,0xcd,0x12,0xff,
    0x00,0x00,0x00,0xff,0xca,0x1d,0x4b,0xff,0x09,0x87,0xd4,0xff,0xaa,0x02,0x05,0xff,
    0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0xc0,0x1d,0x4b,0xff,
    0xcd,0xab,0xba,0xff,0x00,0x00,0x00,0xff,0xa4,0xcd,0x12,0xff,0xc0,0x1d,0x4b,0xff,
    0xd4,0xcd,0x12,0xff,0xa6,0x4c,0xd5,0xff,0x00,0xf0,0xfd,0xff,0xd4,0xcd,0x12,0xff,
    0xf4,0x4c,0xd5,0xff,0x90,0xcd,0x12,0xff,0xc2,0x4c,0xd5,0xff,0x82,0x00,0x00,0xff,
    0xaa,0x02,0x05,0xff,0x88,0xd4,0xba,0xff,0x14,0x00,0x00,0xff,0x01,0x00,0x00,0xff,
    0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0x00,0x00,0x00,0xff,
    0x0c,0x08,0x13,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,
    0xd0,0xcd,0x12,0xff,0xc6,0x84,0xf1,0xff,0x7c,0x84,0xf1,0xff,0x20,0x20,0xf5,0xff,
    0x00,0x00,0x0a,0xff,0xf0,0xb0,0x94,0xff,0x64,0x6c,0xf1,0xff,0x85,0x6c,0xf1,0xff,
    0x8b,0x4f,0xd5,0xff,0x00,0x04,0xda,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff,
    0x39,0xde,0xd4,0xff,0x10,0x50,0xd5,0xff,0xaa,0x02,0x05,0xff,0x00,0x00,0x00,0xff,
    0x4f,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff,0x00,0x00,0x00,0xff,
    0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5c,0xce,0x12,0xff,
    0xaa,0x02,0x05,0xff,0x4c,0xce,0x12,0xff,0x39,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff,
    0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x5b,0xe6,0xd4,0xff,0x00,0x00,0x00,0xff,
    0x00,0x00,0x00,0xff,0x68,0x50,0xcd,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,
    0x00,0x00,0x00,0xff,0x10,0x00,0x00,0xff,0xe3,0xea,0x90,0xff,0x5c,0xce,0x12,0xff,
    0x18,0x00,0x00,0xff,0x88,0xd4,0xba,0xff,0x82,0x00,0x00,0xff,0x00,0x00,0x00,0xff,
    0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01
};

/* 4x4 A8P8 dds file.  */
static const uint8_t dds_a8p8[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
    0x47,0x49,0x4d,0x50,0x2d,0x44,0x44,0x53,0x5a,0x09,0x03,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x10,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0x80,0x00,0x02,0x00,0x80,0x80,0x03,
    0x80,0x00,0x00,0x04,0x80,0x00,0x80,0x05,0x80,0x80,0x00,0x06,0xc0,0xc0,0xc0,0x07,
    0xc0,0xdc,0xc0,0x08,0xf0,0xca,0xa6,0x09,0x00,0x20,0x40,0x0a,0x00,0x20,0x60,0x0b,
    0x00,0x20,0x80,0x0c,0x00,0x20,0xa0,0x0d,0x00,0x20,0xc0,0x0e,0x00,0x20,0xe0,0x0f,
    0x00,0x40,0x00,0x10,0x00,0x40,0x20,0x11,0x00,0x40,0x40,0x12,0x00,0x40,0x60,0x13,
    0x00,0x40,0x80,0x14,0x00,0x40,0xa0,0x15,0x00,0x40,0xc0,0x16,0x00,0x40,0xe0,0x17,
    0x00,0x60,0x00,0x18,0x00,0x60,0x20,0x19,0x00,0x60,0x40,0x1a,0x00,0x60,0x60,0x1b,
    0x00,0x60,0x80,0x1c,0x00,0x60,0xa0,0x1d,0x00,0x60,0xc0,0x1e,0x00,0x60,0xe0,0x1f,
    0x00,0x80,0x00,0x20,0x00,0x80,0x20,0x21,0x00,0x80,0x40,0x22,0x00,0x80,0x60,0x23,
    0x00,0x80,0x80,0x24,0x00,0x80,0xa0,0x25,0x00,0x80,0xc0,0x26,0x00,0x80,0xe0,0x27,
    0x00,0xa0,0x00,0x28,0x00,0xa0,0x20,0x29,0x00,0xa0,0x40,0x2a,0x00,0xa0,0x60,0x2b,
    0x00,0xa0,0x80,0x2c,0x00,0xa0,0xa0,0x2d,0x00,0xa0,0xc0,0x2e,0x00,0xa0,0xe0,0x2f,
    0x00,0xc0,0x00,0x30,0x00,0xc0,0x20,0x31,0x00,0xc0,0x40,0x32,0x00,0xc0,0x60,0x33,
    0x00,0xc0,0x80,0x34,0x00,0xc0,0xa0,0x35,0x00,0xc0,0xc0,0x36,0x00,0xc0,0xe0,0x37,
    0x00,0xe0,0x00,0x38,0x00,0xe0,0x20,0x39,0x00,0xe0,0x40,0x3a,0x00,0xe0,0x60,0x3b,
    0x00,0xe0,0x80,0x3c,0x00,0xe0,0xa0,0x3d,0x00,0xe0,0xc0,0x3e,0x00,0xe0,0xe0,0x3f,
    0x40,0x00,0x00,0x40,0x40,0x00,0x20,0x41,0x40,0x00,0x40,0x42,0x40,0x00,0x60,0x43,
    0x40,0x00,0x80,0x44,0x40,0x00,0xa0,0x45,0x40,0x00,0xc0,0x46,0x40,0x00,0xe0,0x47,
    0x40,0x20,0x00,0x48,0x40,0x20,0x20,0x49,0x40,0x20,0x40,0x4a,0x40,0x20,0x60,0x4b,
    0x40,0x20,0x80,0x4c,0x40,0x20,0xa0,0x4d,0x40,0x20,0xc0,0x4e,0x40,0x20,0xe0,0x4f,
    0x40,0x40,0x00,0x50,0x40,0x40,0x20,0x51,0x40,0x40,0x40,0x52,0x40,0x40,0x60,0x53,
    0x40,0x40,0x80,0x54,0x40,0x40,0xa0,0x55,0x40,0x40,0xc0,0x56,0x40,0x40,0xe0,0x57,
    0x40,0x60,0x00,0x58,0x40,0x60,0x20,0x59,0x40,0x60,0x40,0x5a,0x40,0x60,0x60,0x5b,
    0x40,0x60,0x80,0x5c,0x40,0x60,0xa0,0x5d,0x40,0x60,0xc0,0x5e,0x40,0x60,0xe0,0x5f,
    0x40,0x80,0x00,0x60,0x40,0x80,0x20,0x61,0x40,0x80,0x40,0x62,0x40,0x80,0x60,0x63,
    0x40,0x80,0x80,0x64,0x40,0x80,0xa0,0x65,0x40,0x80,0xc0,0x66,0x40,0x80,0xe0,0x67,
    0x40,0xa0,0x00,0x68,0x40,0xa0,0x20,0x69,0x40,0xa0,0x40,0x6a,0x40,0xa0,0x60,0x6b,
    0x40,0xa0,0x80,0x6c,0x40,0xa0,0xa0,0x6d,0x40,0xa0,0xc0,0x6e,0x40,0xa0,0xe0,0x6f,
    0x40,0xc0,0x00,0x70,0x40,0xc0,0x20,0x71,0x40,0xc0,0x40,0x72,0x40,0xc0,0x60,0x73,
    0x40,0xc0,0x80,0x74,0x40,0xc0,0xa0,0x75,0x40,0xc0,0xc0,0x76,0x40,0xc0,0xe0,0x77,
    0x40,0xe0,0x00,0x78,0x40,0xe0,0x20,0x79,0x40,0xe0,0x40,0x7a,0x40,0xe0,0x60,0x7b,
    0x40,0xe0,0x80,0x7c,0x40,0xe0,0xa0,0x7d,0x40,0xe0,0xc0,0x7e,0x40,0xe0,0xe0,0x7f,
    0x80,0x00,0x00,0x80,0x80,0x00,0x20,0x81,0x80,0x00,0x40,0x82,0x80,0x00,0x60,0x83,
    0x80,0x00,0x80,0x84,0x80,0x00,0xa0,0x85,0x80,0x00,0xc0,0x86,0x80,0x00,0xe0,0x87,
    0x80,0x20,0x00,0x88,0x80,0x20,0x20,0x89,0x80,0x20,0x40,0x8a,0x80,0x20,0x60,0x8b,
    0x80,0x20,0x80,0x8c,0x80,0x20,0xa0,0x8d,0x80,0x20,0xc0,0x8e,0x80,0x20,0xe0,0x8f,
    0x80,0x40,0x00,0x90,0x80,0x40,0x20,0x91,0x80,0x40,0x40,0x92,0x80,0x40,0x60,0x93,
    0x80,0x40,0x80,0x94,0x80,0x40,0xa0,0x95,0x80,0x40,0xc0,0x96,0x80,0x40,0xe0,0x97,
    0x80,0x60,0x00,0x98,0x80,0x60,0x20,0x99,0x80,0x60,0x40,0x9a,0x80,0x60,0x60,0x9b,
    0x80,0x60,0x80,0x9c,0x80,0x60,0xa0,0x9d,0x80,0x60,0xc0,0x9e,0x80,0x60,0xe0,0x9f,
    0x80,0x80,0x00,0xa0,0x80,0x80,0x20,0xa1,0x80,0x80,0x40,0xa2,0x80,0x80,0x60,0xa3,
    0x80,0x80,0x80,0xa4,0x80,0x80,0xa0,0xa5,0x80,0x80,0xc0,0xa6,0x80,0x80,0xe0,0xa7,
    0x80,0xa0,0x00,0xa8,0x80,0xa0,0x20,0xa9,0x80,0xa0,0x40,0xaa,0x80,0xa0,0x60,0xab,
    0x80,0xa0,0x80,0xac,0x80,0xa0,0xa0,0xad,0x80,0xa0,0xc0,0xae,0x80,0xa0,0xe0,0xaf,
    0x80,0xc0,0x00,0xb0,0x80,0xc0,0x20,0xb1,0x80,0xc0,0x40,0xb2,0x80,0xc0,0x60,0xb3,
    0x80,0xc0,0x80,0xb4,0x80,0xc0,0xa0,0xb5,0x80,0xc0,0xc0,0xb6,0x80,0xc0,0xe0,0xb7,
    0x80,0xe0,0x00,0xb8,0x80,0xe0,0x20,0xb9,0x80,0xe0,0x40,0xba,0x80,0xe0,0x60,0xbb,
    0x80,0xe0,0x80,0xbc,0x80,0xe0,0xa0,0xbd,0x80,0xe0,0xc0,0xbe,0x80,0xe0,0xe0,0xbf,
    0xc0,0x00,0x00,0xc0,0xc0,0x00,0x20,0xc1,0xc0,0x00,0x40,0xc2,0xc0,0x00,0x60,0xc3,
    0xc0,0x00,0x80,0xc4,0xc0,0x00,0xa0,0xc5,0xc0,0x00,0xc0,0xc6,0xc0,0x00,0xe0,0xc7,
    0xc0,0x20,0x00,0xc8,0xc0,0x20,0x20,0xc9,0xc0,0x20,0x40,0xca,0xc0,0x20,0x60,0xcb,
    0xc0,0x20,0x80,0xcc,0xc0,0x20,0xa0,0xcd,0xc0,0x20,0xc0,0xce,0xc0,0x20,0xe0,0xcf,
    0xc0,0x40,0x00,0xd0,0xc0,0x40,0x20,0xd1,0xc0,0x40,0x40,0xd2,0xc0,0x40,0x60,0xd3,
    0xc0,0x40,0x80,0xd4,0xc0,0x40,0xa0,0xd5,0xc0,0x40,0xc0,0xd6,0xc0,0x40,0xe0,0xd7,
    0xc0,0x60,0x00,0xd8,0xc0,0x60,0x20,0xd9,0xc0,0x60,0x40,0xda,0xc0,0x60,0x60,0xdb,
    0xc0,0x60,0x80,0xdc,0xc0,0x60,0xa0,0xdd,0xc0,0x60,0xc0,0xde,0xc0,0x60,0xe0,0xdf,
    0xc0,0x80,0x00,0xe0,0xc0,0x80,0x20,0xe1,0xc0,0x80,0x40,0xe2,0xc0,0x80,0x60,0xe3,
    0xc0,0x80,0x80,0xe4,0xc0,0x80,0xa0,0xe5,0xc0,0x80,0xc0,0xe6,0xc0,0x80,0xe0,0xe7,
    0xc0,0xa0,0x00,0xe8,0xc0,0xa0,0x20,0xe9,0xc0,0xa0,0x40,0xea,0xc0,0xa0,0x60,0xeb,
    0xc0,0xa0,0x80,0xec,0xc0,0xa0,0xa0,0xed,0xc0,0xa0,0xc0,0xee,0xc0,0xa0,0xe0,0xef,
    0xc0,0xc0,0x00,0xf0,0xc0,0xc0,0x20,0xf1,0xc0,0xc0,0x40,0xf2,0xc0,0xc0,0x60,0xf3,
    0xc0,0xc0,0x80,0xf4,0xc0,0xc0,0xa0,0xf5,0xf0,0xfb,0xff,0xf6,0xa4,0xa0,0xa0,0xf7,
    0x80,0x80,0x80,0xf8,0x00,0x00,0xff,0xf9,0x00,0xff,0x00,0xfa,0x00,0xff,0xff,0xfb,
    0xff,0x00,0x00,0xfc,0xff,0x00,0xff,0xfd,0xff,0xff,0x00,0xfe,0xff,0xff,0xff,0xff,
    0x00,0xf0,0x10,0xe0,0x20,0xd0,0x30,0xc0,0x40,0xb0,0x50,0xa0,0x60,0x90,0x70,0x80,
    0x80,0x70,0x90,0x60,0xa0,0x50,0xb0,0x40,0xc0,0x30,0xd0,0x20,0xe0,0x10,0xf0,0x00,
};

/* 2x2 24-bit dds, 2 mipmaps */
static const uint8_t dds_24bit[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x02,0x00,0x00,0x00,
    0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};

/* 2x2 16-bit dds, no mipmaps */
static const uint8_t dds_16bit[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00,
    0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,
    0xe0,0x03,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f
};

/* 4x4 cube map dds */
static const uint8_t dds_cube_map[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x04,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
    0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x51,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x52,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x53,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x54,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x55
};

/* 4x2 cube map DDS file. */
static const uint8_t dds_cube_map_4_2[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x02,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
    0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,
    0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,
    0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

/* 2x4 cube map DDS file. */
static const uint8_t dds_cube_map_2_4[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x00,0x00,0x04,0x00,0x00,0x00,
    0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
    0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,
    0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,
    0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

/* 4x4 cube map DDS file with 2 mips. */
static const uint8_t dds_cube_map_4_4[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x02,0x00,0x04,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
    0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
    0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
    0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,
    0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,
    0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,
    0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,
    0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,
    0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,
    0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,
    0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,
    0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,
    0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
    0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
    0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
    0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
    0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,
};

/* 4x4x2 volume map dds, 2 mipmaps */
static const uint8_t dds_volume_map[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
    0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
    0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x2f,0x7e,0xcf,0x79,0x01,0x54,0x5c,0x5c,
    0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab
};

/* 4x2 dxt5 */
static const uint8_t dds_dxt5[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x02,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
};

/* 8x8 dxt5 */
static const uint8_t dds_dxt5_8_8[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x08,0x00,0x08,0x00,0x00,0x00,
    0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x35,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0xe0,0x07,0x05,0x05,0x50,0x50,
    0x3f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x07,0x05,0x05,0x50,0x50,
    0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xf8,0xe0,0xff,0x05,0x05,0x50,0x50,
    0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x05,0x05,0x50,0x50,
};

/*
 * 8x8 dxt5 image data, four 4x4 blocks:
 * +-----+-----+
 * |Blue |Green|
 * |     |     |
 * +-----+-----+
 * |Red  |Black|
 * |     |     |
 * +-----+-----+
 */
static const uint8_t dxt5_8_8[] =
{
    0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x07,0xe0,0x07,0x00,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,0x00,
    0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

/*
 * 4x4x4 24-bit volume dds, 3 mipmaps. Level 0 is red, level 1 is green, level 2 is
 * blue.
 */
static const uint8_t dds_volume_24bit_4_4_4[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x0f,0x10,0x82,0x00,0x04,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
    0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00
};

/*
 * 4x4x4 DXT3 volume dds. 3 mipmaps. Level 0 is red, level 1 is green, level 2 is
 * blue.
 */
static const uint8_t dds_volume_dxt3_4_4_4[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x8a,0x00,0x04,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x44,0x58,0x54,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
    0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf8,0x00,0xf8,0xaa,0xaa,0xaa,0xaa,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x07,0xe0,0x07,0xaa,0xaa,0xaa,0xaa,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x1f,0x00,0xaa,0xaa,0xaa,0xaa,
};

/*
 * 8x8 24-bit dds, 4 mipmaps. Level 0 is red, level 1 is green, level 2 is
 * blue, and level 3 is black.
 */
static const uint8_t dds_24bit_8_8[] =
{
    0x44,0x44,0x53,0x20,0x7c,0x00,0x00,0x00,0x07,0x10,0x0a,0x00,0x08,0x00,0x00,0x00,
    0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,
    0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,
    0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00
};

static const uint8_t a8r8g8b8_16_16[] =
{
    0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
    0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07,
    0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0b,
    0x0c,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x0f,
    0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,0x12,0x12,0x12,0x12,0x13,0x13,0x13,0x13,
    0x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17,0x17,
    0x18,0x18,0x18,0x18,0x19,0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1b,
    0x1c,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x1f,
    0x20,0x20,0x20,0x20,0x21,0x21,0x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23,0x23,0x23,
    0x24,0x24,0x24,0x24,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27,0x27,
    0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2b,
    0x2c,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x2f,
    0x30,0x30,0x30,0x30,0x31,0x31,0x31,0x31,0x32,0x32,0x32,0x32,0x33,0x33,0x33,0x33,
    0x34,0x34,0x34,0x34,0x35,0x35,0x35,0x35,0x36,0x36,0x36,0x36,0x37,0x37,0x37,0x37,
    0x38,0x38,0x38,0x38,0x39,0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3b,
    0x3c,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x3f,
    0x40,0x40,0x40,0x40,0x41,0x41,0x41,0x41,0x42,0x42,0x42,0x42,0x43,0x43,0x43,0x43,
    0x44,0x44,0x44,0x44,0x45,0x45,0x45,0x45,0x46,0x46,0x46,0x46,0x47,0x47,0x47,0x47,
    0x48,0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4b,
    0x4c,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x4f,
    0x50,0x50,0x50,0x50,0x51,0x51,0x51,0x51,0x52,0x52,0x52,0x52,0x53,0x53,0x53,0x53,
    0x54,0x54,0x54,0x54,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,0x57,0x57,0x57,0x57,
    0x58,0x58,0x58,0x58,0x59,0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5b,
    0x5c,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x5f,
    0x60,0x60,0x60,0x60,0x61,0x61,0x61,0x61,0x62,0x62,0x62,0x62,0x63,0x63,0x63,0x63,
    0x64,0x64,0x64,0x64,0x65,0x65,0x65,0x65,0x66,0x66,0x66,0x66,0x67,0x67,0x67,0x67,
    0x68,0x68,0x68,0x68,0x69,0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6b,
    0x6c,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x6f,
    0x70,0x70,0x70,0x70,0x71,0x71,0x71,0x71,0x72,0x72,0x72,0x72,0x73,0x73,0x73,0x73,
    0x74,0x74,0x74,0x74,0x75,0x75,0x75,0x75,0x76,0x76,0x76,0x76,0x77,0x77,0x77,0x77,
    0x78,0x78,0x78,0x78,0x79,0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7b,
    0x7c,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,
    0x80,0x80,0x80,0x80,0x81,0x81,0x81,0x81,0x82,0x82,0x82,0x82,0x83,0x83,0x83,0x83,
    0x84,0x84,0x84,0x84,0x85,0x85,0x85,0x85,0x86,0x86,0x86,0x86,0x87,0x87,0x87,0x87,
    0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,0x8a,0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x8b,
    0x8c,0x8c,0x8c,0x8c,0x8d,0x8d,0x8d,0x8d,0x8e,0x8e,0x8e,0x8e,0x8f,0x8f,0x8f,0x8f,
    0x90,0x90,0x90,0x90,0x91,0x91,0x91,0x91,0x92,0x92,0x92,0x92,0x93,0x93,0x93,0x93,
    0x94,0x94,0x94,0x94,0x95,0x95,0x95,0x95,0x96,0x96,0x96,0x96,0x97,0x97,0x97,0x97,
    0x98,0x98,0x98,0x98,0x99,0x99,0x99,0x99,0x9a,0x9a,0x9a,0x9a,0x9b,0x9b,0x9b,0x9b,
    0x9c,0x9c,0x9c,0x9c,0x9d,0x9d,0x9d,0x9d,0x9e,0x9e,0x9e,0x9e,0x9f,0x9f,0x9f,0x9f,
    0xa0,0xa0,0xa0,0xa0,0xa1,0xa1,0xa1,0xa1,0xa2,0xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa3,
    0xa4,0xa4,0xa4,0xa4,0xa5,0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa6,0xa7,0xa7,0xa7,0xa7,
    0xa8,0xa8,0xa8,0xa8,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,0xaa,0xaa,0xab,0xab,0xab,0xab,
    0xac,0xac,0xac,0xac,0xad,0xad,0xad,0xad,0xae,0xae,0xae,0xae,0xaf,0xaf,0xaf,0xaf,
    0xb0,0xb0,0xb0,0xb0,0xb1,0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb2,0xb3,0xb3,0xb3,0xb3,
    0xb4,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb5,0xb6,0xb6,0xb6,0xb6,0xb7,0xb7,0xb7,0xb7,
    0xb8,0xb8,0xb8,0xb8,0xb9,0xb9,0xb9,0xb9,0xba,0xba,0xba,0xba,0xbb,0xbb,0xbb,0xbb,
    0xbc,0xbc,0xbc,0xbc,0xbd,0xbd,0xbd,0xbd,0xbe,0xbe,0xbe,0xbe,0xbf,0xbf,0xbf,0xbf,
    0xc0,0xc0,0xc0,0xc0,0xc1,0xc1,0xc1,0xc1,0xc2,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3,0xc3,
    0xc4,0xc4,0xc4,0xc4,0xc5,0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xc6,0xc7,0xc7,0xc7,0xc7,
    0xc8,0xc8,0xc8,0xc8,0xc9,0xc9,0xc9,0xc9,0xca,0xca,0xca,0xca,0xcb,0xcb,0xcb,0xcb,
    0xcc,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xcd,0xce,0xce,0xce,0xce,0xcf,0xcf,0xcf,0xcf,
    0xd0,0xd0,0xd0,0xd0,0xd1,0xd1,0xd1,0xd1,0xd2,0xd2,0xd2,0xd2,0xd3,0xd3,0xd3,0xd3,
    0xd4,0xd4,0xd4,0xd4,0xd5,0xd5,0xd5,0xd5,0xd6,0xd6,0xd6,0xd6,0xd7,0xd7,0xd7,0xd7,
    0xd8,0xd8,0xd8,0xd8,0xd9,0xd9,0xd9,0xd9,0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,
    0xdc,0xdc,0xdc,0xdc,0xdd,0xdd,0xdd,0xdd,0xde,0xde,0xde,0xde,0xdf,0xdf,0xdf,0xdf,
    0xe0,0xe0,0xe0,0xe0,0xe1,0xe1,0xe1,0xe1,0xe2,0xe2,0xe2,0xe2,0xe3,0xe3,0xe3,0xe3,
    0xe4,0xe4,0xe4,0xe4,0xe5,0xe5,0xe5,0xe5,0xe6,0xe6,0xe6,0xe6,0xe7,0xe7,0xe7,0xe7,
    0xe8,0xe8,0xe8,0xe8,0xe9,0xe9,0xe9,0xe9,0xea,0xea,0xea,0xea,0xeb,0xeb,0xeb,0xeb,
    0xec,0xec,0xec,0xec,0xed,0xed,0xed,0xed,0xee,0xee,0xee,0xee,0xef,0xef,0xef,0xef,
    0xf0,0xf0,0xf0,0xf0,0xf1,0xf1,0xf1,0xf1,0xf2,0xf2,0xf2,0xf2,0xf3,0xf3,0xf3,0xf3,
    0xf4,0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf6,0xf6,0xf6,0xf6,0xf7,0xf7,0xf7,0xf7,
    0xf8,0xf8,0xf8,0xf8,0xf9,0xf9,0xf9,0xf9,0xfa,0xfa,0xfa,0xfa,0xfb,0xfb,0xfb,0xfb,
    0xfc,0xfc,0xfc,0xfc,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff,
};

static const uint8_t a8r8g8b8_16_16_point_filter_8_8[] =
{
    0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x06,0x06,0x06,0x06,
    0x08,0x08,0x08,0x08,0x0a,0x0a,0x0a,0x0a,0x0c,0x0c,0x0c,0x0c,0x0e,0x0e,0x0e,0x0e,
    0x20,0x20,0x20,0x20,0x22,0x22,0x22,0x22,0x24,0x24,0x24,0x24,0x26,0x26,0x26,0x26,
    0x28,0x28,0x28,0x28,0x2a,0x2a,0x2a,0x2a,0x2c,0x2c,0x2c,0x2c,0x2e,0x2e,0x2e,0x2e,
    0x40,0x40,0x40,0x40,0x42,0x42,0x42,0x42,0x44,0x44,0x44,0x44,0x46,0x46,0x46,0x46,
    0x48,0x48,0x48,0x48,0x4a,0x4a,0x4a,0x4a,0x4c,0x4c,0x4c,0x4c,0x4e,0x4e,0x4e,0x4e,
    0x60,0x60,0x60,0x60,0x62,0x62,0x62,0x62,0x64,0x64,0x64,0x64,0x66,0x66,0x66,0x66,
    0x68,0x68,0x68,0x68,0x6a,0x6a,0x6a,0x6a,0x6c,0x6c,0x6c,0x6c,0x6e,0x6e,0x6e,0x6e,
    0x80,0x80,0x80,0x80,0x82,0x82,0x82,0x82,0x84,0x84,0x84,0x84,0x86,0x86,0x86,0x86,
    0x88,0x88,0x88,0x88,0x8a,0x8a,0x8a,0x8a,0x8c,0x8c,0x8c,0x8c,0x8e,0x8e,0x8e,0x8e,
    0xa0,0xa0,0xa0,0xa0,0xa2,0xa2,0xa2,0xa2,0xa4,0xa4,0xa4,0xa4,0xa6,0xa6,0xa6,0xa6,
    0xa8,0xa8,0xa8,0xa8,0xaa,0xaa,0xaa,0xaa,0xac,0xac,0xac,0xac,0xae,0xae,0xae,0xae,
    0xc0,0xc0,0xc0,0xc0,0xc2,0xc2,0xc2,0xc2,0xc4,0xc4,0xc4,0xc4,0xc6,0xc6,0xc6,0xc6,
    0xc8,0xc8,0xc8,0xc8,0xca,0xca,0xca,0xca,0xcc,0xcc,0xcc,0xcc,0xce,0xce,0xce,0xce,
    0xe0,0xe0,0xe0,0xe0,0xe2,0xe2,0xe2,0xe2,0xe4,0xe4,0xe4,0xe4,0xe6,0xe6,0xe6,0xe6,
    0xe8,0xe8,0xe8,0xe8,0xea,0xea,0xea,0xea,0xec,0xec,0xec,0xec,0xee,0xee,0xee,0xee,
};

static const uint8_t a8r8g8b8_16_16_linear_filter_8_8[] =
{
    0x09,0x09,0x09,0x09,0x0b,0x0b,0x0b,0x0b,0x0d,0x0d,0x0d,0x0d,0x0f,0x0f,0x0f,0x0f,
    0x11,0x11,0x11,0x11,0x13,0x13,0x13,0x13,0x15,0x15,0x15,0x15,0x17,0x17,0x17,0x17,
    0x29,0x29,0x29,0x29,0x2b,0x2b,0x2b,0x2b,0x2d,0x2d,0x2d,0x2d,0x2f,0x2f,0x2f,0x2f,
    0x31,0x31,0x31,0x31,0x33,0x33,0x33,0x33,0x35,0x35,0x35,0x35,0x37,0x37,0x37,0x37,
    0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,0x4d,0x4d,0x4d,0x4d,0x4f,0x4f,0x4f,0x4f,
    0x51,0x51,0x51,0x51,0x53,0x53,0x53,0x53,0x55,0x55,0x55,0x55,0x57,0x57,0x57,0x57,
    0x69,0x69,0x69,0x69,0x6b,0x6b,0x6b,0x6b,0x6d,0x6d,0x6d,0x6d,0x6f,0x6f,0x6f,0x6f,
    0x71,0x71,0x71,0x71,0x73,0x73,0x73,0x73,0x75,0x75,0x75,0x75,0x77,0x77,0x77,0x77,
    0x89,0x89,0x89,0x89,0x8b,0x8b,0x8b,0x8b,0x8d,0x8d,0x8d,0x8d,0x8f,0x8f,0x8f,0x8f,
    0x91,0x91,0x91,0x91,0x93,0x93,0x93,0x93,0x95,0x95,0x95,0x95,0x97,0x97,0x97,0x97,
    0xa9,0xa9,0xa9,0xa9,0xab,0xab,0xab,0xab,0xad,0xad,0xad,0xad,0xaf,0xaf,0xaf,0xaf,
    0xb1,0xb1,0xb1,0xb1,0xb3,0xb3,0xb3,0xb3,0xb5,0xb5,0xb5,0xb5,0xb7,0xb7,0xb7,0xb7,
    0xc9,0xc9,0xc9,0xc9,0xcb,0xcb,0xcb,0xcb,0xcd,0xcd,0xcd,0xcd,0xcf,0xcf,0xcf,0xcf,
    0xd1,0xd1,0xd1,0xd1,0xd3,0xd3,0xd3,0xd3,0xd5,0xd5,0xd5,0xd5,0xd7,0xd7,0xd7,0xd7,
    0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xed,0xed,0xed,0xed,0xef,0xef,0xef,0xef,
    0xf1,0xf1,0xf1,0xf1,0xf3,0xf3,0xf3,0xf3,0xf5,0xf5,0xf5,0xf5,0xf7,0xf7,0xf7,0xf7,
};

static const uint8_t a8r8g8b8_16_16_triangle_filter_8_8[] =
{
    0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1b,0x1d,0x1d,0x1d,0x1d,0x1f,0x1f,0x1f,0x1f,
    0x21,0x21,0x21,0x21,0x23,0x23,0x23,0x23,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,
    0x2a,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2b,0x2d,0x2d,0x2d,0x2d,0x2f,0x2f,0x2f,0x2f,
    0x31,0x31,0x31,0x31,0x33,0x33,0x33,0x33,0x35,0x35,0x35,0x35,0x36,0x36,0x36,0x36,
    0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,0x4d,0x4d,0x4d,0x4d,0x4f,0x4f,0x4f,0x4f,
    0x51,0x51,0x51,0x51,0x53,0x53,0x53,0x53,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,
    0x6a,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6b,0x6d,0x6d,0x6d,0x6d,0x6f,0x6f,0x6f,0x6f,
    0x71,0x71,0x71,0x71,0x73,0x73,0x73,0x73,0x75,0x75,0x75,0x75,0x76,0x76,0x76,0x76,
    0x8a,0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x8b,0x8d,0x8d,0x8d,0x8d,0x8f,0x8f,0x8f,0x8f,
    0x91,0x91,0x91,0x91,0x93,0x93,0x93,0x93,0x95,0x95,0x95,0x95,0x96,0x96,0x96,0x96,
    0xaa,0xaa,0xaa,0xaa,0xab,0xab,0xab,0xab,0xad,0xad,0xad,0xad,0xaf,0xaf,0xaf,0xaf,
    0xb1,0xb1,0xb1,0xb1,0xb3,0xb3,0xb3,0xb3,0xb5,0xb5,0xb5,0xb5,0xb6,0xb6,0xb6,0xb6,
    0xca,0xca,0xca,0xca,0xcb,0xcb,0xcb,0xcb,0xcd,0xcd,0xcd,0xcd,0xcf,0xcf,0xcf,0xcf,
    0xd1,0xd1,0xd1,0xd1,0xd3,0xd3,0xd3,0xd3,0xd5,0xd5,0xd5,0xd5,0xd6,0xd6,0xd6,0xd6,
    0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,0xdd,0xdd,0xdd,0xdd,0xdf,0xdf,0xdf,0xdf,
    0xe1,0xe1,0xe1,0xe1,0xe3,0xe3,0xe3,0xe3,0xe5,0xe5,0xe5,0xe5,0xe6,0xe6,0xe6,0xe6,
};

static const uint8_t a8r8g8b8_16_16_triangle_filter_8_8_32bit[] =
{
    0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1b,0x1d,0x1d,0x1d,0x1d,0x1f,0x1f,0x1f,0x1f,
    0x21,0x21,0x21,0x21,0x23,0x23,0x23,0x23,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,
    0x2a,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2b,0x2d,0x2d,0x2d,0x2d,0x2f,0x2f,0x2f,0x2f,
    0x31,0x31,0x31,0x31,0x33,0x33,0x33,0x33,0x35,0x35,0x35,0x35,0x36,0x36,0x36,0x36,
    0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,0x4d,0x4d,0x4d,0x4d,0x4f,0x4f,0x4f,0x4f,
    0x51,0x51,0x51,0x51,0x53,0x53,0x53,0x53,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,
    0x6a,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6b,0x6d,0x6d,0x6d,0x6d,0x6f,0x6f,0x6f,0x6f,
    0x71,0x71,0x71,0x71,0x73,0x73,0x73,0x73,0x75,0x75,0x75,0x75,0x76,0x76,0x76,0x76,
    0x8a,0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x8b,0x8d,0x8d,0x8d,0x8d,0x8f,0x8f,0x8f,0x8f,
    0x91,0x91,0x91,0x91,0x93,0x93,0x93,0x93,0x95,0x95,0x95,0x95,0x96,0x96,0x96,0x96,
    0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xac,0xac,0xac,0xac,0xae,0xae,0xae,0xae,
    0xb1,0xb1,0xb1,0xb1,0xb3,0xb3,0xb3,0xb3,0xb5,0xb5,0xb5,0xb5,0xb6,0xb6,0xb6,0xb6,
    0xca,0xca,0xca,0xca,0xcb,0xcb,0xcb,0xcb,0xcd,0xcd,0xcd,0xcd,0xcf,0xcf,0xcf,0xcf,
    0xd1,0xd1,0xd1,0xd1,0xd2,0xd2,0xd2,0xd2,0xd5,0xd5,0xd5,0xd5,0xd6,0xd6,0xd6,0xd6,
    0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,0xdd,0xdd,0xdd,0xdd,0xdf,0xdf,0xdf,0xdf,
    0xe1,0xe1,0xe1,0xe1,0xe3,0xe3,0xe3,0xe3,0xe5,0xe5,0xe5,0xe5,0xe6,0xe6,0xe6,0xe6,
};

static const uint8_t a8r8g8b8_16_16_point_filter_7_7[] =
{
    0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x06,0x06,0x06,0x06,
    0x09,0x09,0x09,0x09,0x0b,0x0b,0x0b,0x0b,0x0d,0x0d,0x0d,0x0d,0x20,0x20,0x20,0x20,
    0x22,0x22,0x22,0x22,0x24,0x24,0x24,0x24,0x26,0x26,0x26,0x26,0x29,0x29,0x29,0x29,
    0x2b,0x2b,0x2b,0x2b,0x2d,0x2d,0x2d,0x2d,0x40,0x40,0x40,0x40,0x42,0x42,0x42,0x42,
    0x44,0x44,0x44,0x44,0x46,0x46,0x46,0x46,0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,
    0x4d,0x4d,0x4d,0x4d,0x60,0x60,0x60,0x60,0x62,0x62,0x62,0x62,0x64,0x64,0x64,0x64,
    0x66,0x66,0x66,0x66,0x69,0x69,0x69,0x69,0x6b,0x6b,0x6b,0x6b,0x6d,0x6d,0x6d,0x6d,
    0x90,0x90,0x90,0x90,0x92,0x92,0x92,0x92,0x94,0x94,0x94,0x94,0x96,0x96,0x96,0x96,
    0x99,0x99,0x99,0x99,0x9b,0x9b,0x9b,0x9b,0x9d,0x9d,0x9d,0x9d,0xb0,0xb0,0xb0,0xb0,
    0xb2,0xb2,0xb2,0xb2,0xb4,0xb4,0xb4,0xb4,0xb6,0xb6,0xb6,0xb6,0xb9,0xb9,0xb9,0xb9,
    0xbb,0xbb,0xbb,0xbb,0xbd,0xbd,0xbd,0xbd,0xd0,0xd0,0xd0,0xd0,0xd2,0xd2,0xd2,0xd2,
    0xd4,0xd4,0xd4,0xd4,0xd6,0xd6,0xd6,0xd6,0xd9,0xd9,0xd9,0xd9,0xdb,0xdb,0xdb,0xdb,
    0xdd,0xdd,0xdd,0xdd,
};

static const uint8_t a8r8g8b8_16_16_linear_filter_7_7[] =
{
    0x0b,0x0b,0x0b,0x0b,0x0d,0x0d,0x0d,0x0d,0x10,0x10,0x10,0x10,0x12,0x12,0x12,0x12,
    0x14,0x14,0x14,0x14,0x16,0x16,0x16,0x16,0x19,0x19,0x19,0x19,0x30,0x30,0x30,0x30,
    0x32,0x32,0x32,0x32,0x34,0x34,0x34,0x34,0x36,0x36,0x36,0x36,0x39,0x39,0x39,0x39,
    0x3b,0x3b,0x3b,0x3b,0x3d,0x3d,0x3d,0x3d,0x54,0x54,0x54,0x54,0x56,0x56,0x56,0x56,
    0x59,0x59,0x59,0x59,0x5b,0x5b,0x5b,0x5b,0x5d,0x5d,0x5d,0x5d,0x60,0x60,0x60,0x60,
    0x62,0x62,0x62,0x62,0x79,0x79,0x79,0x79,0x7b,0x7b,0x7b,0x7b,0x7d,0x7d,0x7d,0x7d,
    0x80,0x80,0x80,0x80,0x82,0x82,0x82,0x82,0x84,0x84,0x84,0x84,0x86,0x86,0x86,0x86,
    0x9d,0x9d,0x9d,0x9d,0xa0,0xa0,0xa0,0xa0,0xa2,0xa2,0xa2,0xa2,0xa4,0xa4,0xa4,0xa4,
    0xa6,0xa6,0xa6,0xa6,0xa9,0xa9,0xa9,0xa9,0xab,0xab,0xab,0xab,0xc2,0xc2,0xc2,0xc2,
    0xc4,0xc4,0xc4,0xc4,0xc6,0xc6,0xc6,0xc6,0xc9,0xc9,0xc9,0xc9,0xcb,0xcb,0xcb,0xcb,
    0xcd,0xcd,0xcd,0xcd,0xd0,0xd0,0xd0,0xd0,0xe6,0xe6,0xe6,0xe6,0xe9,0xe9,0xe9,0xe9,
    0xeb,0xeb,0xeb,0xeb,0xed,0xed,0xed,0xed,0xf0,0xf0,0xf0,0xf0,0xf2,0xf2,0xf2,0xf2,
    0xf4,0xf4,0xf4,0xf4,
};

static const uint8_t a8r8g8b8_16_16_triangle_filter_7_7[] =
{
    0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1b,0x1e,0x1e,0x1e,0x1e,0x20,0x20,0x20,0x20,
    0x22,0x22,0x22,0x22,0x24,0x24,0x24,0x24,0x26,0x26,0x26,0x26,0x30,0x30,0x30,0x30,
    0x32,0x32,0x32,0x32,0x34,0x34,0x34,0x34,0x36,0x36,0x36,0x36,0x39,0x39,0x39,0x39,
    0x3b,0x3b,0x3b,0x3b,0x3c,0x3c,0x3c,0x3c,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,
    0x59,0x59,0x59,0x59,0x5b,0x5b,0x5b,0x5b,0x5d,0x5d,0x5d,0x5d,0x60,0x60,0x60,0x60,
    0x61,0x61,0x61,0x61,0x7a,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7b,0x7d,0x7d,0x7d,0x7d,
    0x80,0x80,0x80,0x80,0x82,0x82,0x82,0x82,0x84,0x84,0x84,0x84,0x85,0x85,0x85,0x85,
    0x9e,0x9e,0x9e,0x9e,0xa0,0xa0,0xa0,0xa0,0xa2,0xa2,0xa2,0xa2,0xa4,0xa4,0xa4,0xa4,
    0xa6,0xa6,0xa6,0xa6,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,0xaa,0xaa,0xc3,0xc3,0xc3,0xc3,
    0xc4,0xc4,0xc4,0xc4,0xc6,0xc6,0xc6,0xc6,0xc9,0xc9,0xc9,0xc9,0xcb,0xcb,0xcb,0xcb,
    0xcd,0xcd,0xcd,0xcd,0xcf,0xcf,0xcf,0xcf,0xd9,0xd9,0xd9,0xd9,0xdb,0xdb,0xdb,0xdb,
    0xdd,0xdd,0xdd,0xdd,0xdf,0xdf,0xdf,0xdf,0xe1,0xe1,0xe1,0xe1,0xe4,0xe4,0xe4,0xe4,
    0xe5,0xe5,0xe5,0xe5,
};

static const uint8_t a8r8g8b8_6_6[] =
{
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x18,0x18,0x24,0x24,0x24,0x24,
    0x30,0x30,0x30,0x30,0x3c,0x3c,0x3c,0x3c,0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,
    0x40,0x40,0x40,0x40,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,0x64,0x64,0x64,0x64,
    0x50,0x50,0x50,0x50,0x5c,0x5c,0x5c,0x5c,0x68,0x68,0x68,0x68,0x74,0x74,0x74,0x74,
    0x80,0x80,0x80,0x80,0x8c,0x8c,0x8c,0x8c,0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,
    0x90,0x90,0x90,0x90,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,0xb4,0xb4,0xb4,0xb4,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xb8,0xb8,0xb8,0xb8,0xc4,0xc4,0xc4,0xc4,
    0xd0,0xd0,0xd0,0xd0,0xdc,0xdc,0xdc,0xdc,0xc8,0xc8,0xc8,0xc8,0xd4,0xd4,0xd4,0xd4,
    0xe0,0xe0,0xe0,0xe0,0xec,0xec,0xec,0xec,0xf8,0xf8,0xf8,0xf8,0xff,0xff,0xff,0xff,
};

static const uint8_t a8r8g8b8_6_6_point_filter_3_3[] =
{
    0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x30,0x30,0x30,0x30,0x50,0x50,0x50,0x50,
    0x68,0x68,0x68,0x68,0x80,0x80,0x80,0x80,0xa0,0xa0,0xa0,0xa0,0xb8,0xb8,0xb8,0xb8,
    0xd0,0xd0,0xd0,0xd0,
};
static const uint8_t a8r8g8b8_6_6_linear_filter_3_3[] =
{
    0x1a,0x1a,0x1a,0x1a,0x32,0x32,0x32,0x32,0x4a,0x4a,0x4a,0x4a,0x6a,0x6a,0x6a,0x6a,
    0x82,0x82,0x82,0x82,0x9a,0x9a,0x9a,0x9a,0xba,0xba,0xba,0xba,0xd2,0xd2,0xd2,0xd2,
    0xe9,0xe9,0xe9,0xe9,
};

static const uint8_t a8r8g8b8_6_6_triangle_filter_3_3[] =
{
    0x2d,0x2d,0x2d,0x2d,0x41,0x41,0x41,0x41,0x54,0x54,0x54,0x54,0x6f,0x6f,0x6f,0x6f,
    0x82,0x82,0x82,0x82,0x96,0x96,0x96,0x96,0xaf,0xaf,0xaf,0xaf,0xc3,0xc3,0xc3,0xc3,
    0xd6,0xd6,0xd6,0xd6,
};

static const uint8_t a8r8g8b8_6_6_triangle_dither_filter_3_3[] =
{
    0x2e,0x2e,0x2e,0x2e,0x41,0x41,0x41,0x41,0x55,0x55,0x55,0x55,0x6e,0x6e,0x6e,0x6e,
    0x82,0x82,0x82,0x82,0x95,0x95,0x95,0x95,0xb0,0xb0,0xb0,0xb0,0xc3,0xc3,0xc3,0xc3,
    0xd6,0xd6,0xd6,0xd6,
};

static const uint8_t a8r8g8b8_6_6_point_filter_4_4[] =
{
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x24,0x24,0x24,0x24,0x30,0x30,0x30,0x30,
    0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,
    0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xc4,0xc4,0xc4,0xc4,0xd0,0xd0,0xd0,0xd0,
};

static const uint8_t a8r8g8b8_6_6_linear_filter_4_4[] =
{
    0x0d,0x0d,0x0d,0x0d,0x1f,0x1f,0x1f,0x1f,0x31,0x31,0x31,0x31,0x43,0x43,0x43,0x43,
    0x49,0x49,0x49,0x49,0x5b,0x5b,0x5b,0x5b,0x6d,0x6d,0x6d,0x6d,0x7f,0x7f,0x7f,0x7f,
    0x85,0x85,0x85,0x85,0x97,0x97,0x97,0x97,0xa9,0xa9,0xa9,0xa9,0xbb,0xbb,0xbb,0xbb,
    0xc1,0xc1,0xc1,0xc1,0xd3,0xd3,0xd3,0xd3,0xe5,0xe5,0xe5,0xe5,0xf4,0xf4,0xf4,0xf4,
};

static const uint8_t a8r8g8b8_6_6_triangle_filter_4_4[] =
{
    0x27,0x27,0x27,0x27,0x33,0x33,0x33,0x33,0x45,0x45,0x45,0x45,0x51,0x51,0x51,0x51,
    0x4f,0x4f,0x4f,0x4f,0x5b,0x5b,0x5b,0x5b,0x6d,0x6d,0x6d,0x6d,0x79,0x79,0x79,0x79,
    0x8b,0x8b,0x8b,0x8b,0x97,0x97,0x97,0x97,0xa9,0xa9,0xa9,0xa9,0xb5,0xb5,0xb5,0xb5,
    0xb3,0xb3,0xb3,0xb3,0xbf,0xbf,0xbf,0xbf,0xd1,0xd1,0xd1,0xd1,0xdb,0xdb,0xdb,0xdb,
};

static const uint8_t a8r8g8b8_4_4[] =
{
    0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,0x30,0x30,0x30,0x30,
    0x40,0x40,0x40,0x40,0x50,0x50,0x50,0x50,0x60,0x60,0x60,0x60,0x70,0x70,0x70,0x70,
    0x80,0x80,0x80,0x80,0x90,0x90,0x90,0x90,0xa0,0xa0,0xa0,0xa0,0xb0,0xb0,0xb0,0xb0,
    0xc0,0xc0,0xc0,0xc0,0xd0,0xd0,0xd0,0xd0,0xe0,0xe0,0xe0,0xe0,0xf0,0xf0,0xf0,0xf0,
};

static const uint8_t a8r8g8b8_4_4_point_filter_12_12[] =
{
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
    0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x60,0x60,0x60,0x60,
    0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,
    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
    0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x60,0x60,0x60,0x60,
    0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,
    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
    0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x60,0x60,0x60,0x60,
    0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
    0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0xa0,0xa0,0xa0,0xa0,
    0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
    0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0xa0,0xa0,0xa0,0xa0,
    0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
    0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0xa0,0xa0,0xa0,0xa0,
    0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,
    0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
    0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xe0,0xe0,0xe0,0xe0,
    0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
    0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
    0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xe0,0xe0,0xe0,0xe0,
    0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
};

static const uint8_t a8r8g8b8_4_4_linear_filter_12_12[] =
{
    0x50,0x50,0x50,0x50,0x40,0x40,0x40,0x40,0x45,0x45,0x45,0x45,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x55,0x55,0x55,0x55,0x5b,0x5b,0x5b,0x5b,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x6b,0x6b,0x6b,0x6b,0x70,0x70,0x70,0x70,0x60,0x60,0x60,0x60,
    0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x0b,0x0b,0x0b,0x0b,
    0x10,0x10,0x10,0x10,0x15,0x15,0x15,0x15,0x1b,0x1b,0x1b,0x1b,0x20,0x20,0x20,0x20,
    0x25,0x25,0x25,0x25,0x2b,0x2b,0x2b,0x2b,0x30,0x30,0x30,0x30,0x20,0x20,0x20,0x20,
    0x25,0x25,0x25,0x25,0x15,0x15,0x15,0x15,0x1b,0x1b,0x1b,0x1b,0x20,0x20,0x20,0x20,
    0x25,0x25,0x25,0x25,0x2b,0x2b,0x2b,0x2b,0x30,0x30,0x30,0x30,0x35,0x35,0x35,0x35,
    0x3b,0x3b,0x3b,0x3b,0x40,0x40,0x40,0x40,0x45,0x45,0x45,0x45,0x35,0x35,0x35,0x35,
    0x3b,0x3b,0x3b,0x3b,0x2b,0x2b,0x2b,0x2b,0x30,0x30,0x30,0x30,0x35,0x35,0x35,0x35,
    0x3b,0x3b,0x3b,0x3b,0x40,0x40,0x40,0x40,0x45,0x45,0x45,0x45,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x55,0x55,0x55,0x55,0x5b,0x5b,0x5b,0x5b,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x40,0x40,0x40,0x40,0x45,0x45,0x45,0x45,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x55,0x55,0x55,0x55,0x5b,0x5b,0x5b,0x5b,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x6b,0x6b,0x6b,0x6b,0x70,0x70,0x70,0x70,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x55,0x55,0x55,0x55,0x5b,0x5b,0x5b,0x5b,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x6b,0x6b,0x6b,0x6b,0x70,0x70,0x70,0x70,0x75,0x75,0x75,0x75,
    0x7b,0x7b,0x7b,0x7b,0x80,0x80,0x80,0x80,0x85,0x85,0x85,0x85,0x75,0x75,0x75,0x75,
    0x7b,0x7b,0x7b,0x7b,0x6b,0x6b,0x6b,0x6b,0x70,0x70,0x70,0x70,0x75,0x75,0x75,0x75,
    0x7b,0x7b,0x7b,0x7b,0x80,0x80,0x80,0x80,0x85,0x85,0x85,0x85,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x95,0x95,0x95,0x95,0x9b,0x9b,0x9b,0x9b,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x80,0x80,0x80,0x80,0x85,0x85,0x85,0x85,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x95,0x95,0x95,0x95,0x9b,0x9b,0x9b,0x9b,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0xab,0xab,0xab,0xab,0xb0,0xb0,0xb0,0xb0,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0x95,0x95,0x95,0x95,0x9b,0x9b,0x9b,0x9b,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0xab,0xab,0xab,0xab,0xb0,0xb0,0xb0,0xb0,0xb5,0xb5,0xb5,0xb5,
    0xbb,0xbb,0xbb,0xbb,0xc0,0xc0,0xc0,0xc0,0xc5,0xc5,0xc5,0xc5,0xb5,0xb5,0xb5,0xb5,
    0xbb,0xbb,0xbb,0xbb,0xab,0xab,0xab,0xab,0xb0,0xb0,0xb0,0xb0,0xb5,0xb5,0xb5,0xb5,
    0xbb,0xbb,0xbb,0xbb,0xc0,0xc0,0xc0,0xc0,0xc5,0xc5,0xc5,0xc5,0xcb,0xcb,0xcb,0xcb,
    0xd0,0xd0,0xd0,0xd0,0xd5,0xd5,0xd5,0xd5,0xdb,0xdb,0xdb,0xdb,0xcb,0xcb,0xcb,0xcb,
    0xd0,0xd0,0xd0,0xd0,0xc0,0xc0,0xc0,0xc0,0xc5,0xc5,0xc5,0xc5,0xcb,0xcb,0xcb,0xcb,
    0xd0,0xd0,0xd0,0xd0,0xd5,0xd5,0xd5,0xd5,0xdb,0xdb,0xdb,0xdb,0xe0,0xe0,0xe0,0xe0,
    0xe5,0xe5,0xe5,0xe5,0xeb,0xeb,0xeb,0xeb,0xf0,0xf0,0xf0,0xf0,0xe0,0xe0,0xe0,0xe0,
    0x90,0x90,0x90,0x90,0x80,0x80,0x80,0x80,0x85,0x85,0x85,0x85,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x95,0x95,0x95,0x95,0x9b,0x9b,0x9b,0x9b,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0xab,0xab,0xab,0xab,0xb0,0xb0,0xb0,0xb0,0xa0,0xa0,0xa0,0xa0,
};

static const uint8_t a8r8g8b8_4_4_triangle_filter_12_12[] =
{
    0x50,0x50,0x50,0x50,0x43,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x55,0x55,0x55,0x55,0x5b,0x5b,0x5b,0x5b,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x6b,0x6b,0x6b,0x6b,0x6d,0x6d,0x6d,0x6d,0x60,0x60,0x60,0x60,
    0x1b,0x1b,0x1b,0x1b,0x0d,0x0d,0x0d,0x0d,0x10,0x10,0x10,0x10,0x15,0x15,0x15,0x15,
    0x1b,0x1b,0x1b,0x1b,0x20,0x20,0x20,0x20,0x25,0x25,0x25,0x25,0x2b,0x2b,0x2b,0x2b,
    0x30,0x30,0x30,0x30,0x35,0x35,0x35,0x35,0x38,0x38,0x38,0x38,0x2b,0x2b,0x2b,0x2b,
    0x25,0x25,0x25,0x25,0x18,0x18,0x18,0x18,0x1b,0x1b,0x1b,0x1b,0x20,0x20,0x20,0x20,
    0x25,0x25,0x25,0x25,0x2b,0x2b,0x2b,0x2b,0x30,0x30,0x30,0x30,0x35,0x35,0x35,0x35,
    0x3b,0x3b,0x3b,0x3b,0x40,0x40,0x40,0x40,0x43,0x43,0x43,0x43,0x35,0x35,0x35,0x35,
    0x3b,0x3b,0x3b,0x3b,0x2d,0x2d,0x2d,0x2d,0x30,0x30,0x30,0x30,0x35,0x35,0x35,0x35,
    0x3b,0x3b,0x3b,0x3b,0x40,0x40,0x40,0x40,0x45,0x45,0x45,0x45,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x55,0x55,0x55,0x55,0x58,0x58,0x58,0x58,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x43,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x4b,0x4b,0x4b,0x4b,
    0x50,0x50,0x50,0x50,0x55,0x55,0x55,0x55,0x5b,0x5b,0x5b,0x5b,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x6b,0x6b,0x6b,0x6b,0x6d,0x6d,0x6d,0x6d,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x58,0x58,0x58,0x58,0x5b,0x5b,0x5b,0x5b,0x60,0x60,0x60,0x60,
    0x65,0x65,0x65,0x65,0x6b,0x6b,0x6b,0x6b,0x70,0x70,0x70,0x70,0x75,0x75,0x75,0x75,
    0x7b,0x7b,0x7b,0x7b,0x80,0x80,0x80,0x80,0x83,0x83,0x83,0x83,0x75,0x75,0x75,0x75,
    0x7b,0x7b,0x7b,0x7b,0x6d,0x6d,0x6d,0x6d,0x70,0x70,0x70,0x70,0x75,0x75,0x75,0x75,
    0x7b,0x7b,0x7b,0x7b,0x80,0x80,0x80,0x80,0x85,0x85,0x85,0x85,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x95,0x95,0x95,0x95,0x98,0x98,0x98,0x98,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x83,0x83,0x83,0x83,0x85,0x85,0x85,0x85,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x95,0x95,0x95,0x95,0x9b,0x9b,0x9b,0x9b,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0xab,0xab,0xab,0xab,0xad,0xad,0xad,0xad,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0x98,0x98,0x98,0x98,0x9b,0x9b,0x9b,0x9b,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0xab,0xab,0xab,0xab,0xb0,0xb0,0xb0,0xb0,0xb5,0xb5,0xb5,0xb5,
    0xbb,0xbb,0xbb,0xbb,0xc0,0xc0,0xc0,0xc0,0xc3,0xc3,0xc3,0xc3,0xb5,0xb5,0xb5,0xb5,
    0xbb,0xbb,0xbb,0xbb,0xad,0xad,0xad,0xad,0xb0,0xb0,0xb0,0xb0,0xb5,0xb5,0xb5,0xb5,
    0xbb,0xbb,0xbb,0xbb,0xc0,0xc0,0xc0,0xc0,0xc5,0xc5,0xc5,0xc5,0xcb,0xcb,0xcb,0xcb,
    0xd0,0xd0,0xd0,0xd0,0xd5,0xd5,0xd5,0xd5,0xd8,0xd8,0xd8,0xd8,0xcb,0xcb,0xcb,0xcb,
    0xc5,0xc5,0xc5,0xc5,0xb8,0xb8,0xb8,0xb8,0xbb,0xbb,0xbb,0xbb,0xc0,0xc0,0xc0,0xc0,
    0xc5,0xc5,0xc5,0xc5,0xcb,0xcb,0xcb,0xcb,0xd0,0xd0,0xd0,0xd0,0xd5,0xd5,0xd5,0xd5,
    0xdb,0xdb,0xdb,0xdb,0xe0,0xe0,0xe0,0xe0,0xe3,0xe3,0xe3,0xe3,0xd5,0xd5,0xd5,0xd5,
    0x90,0x90,0x90,0x90,0x83,0x83,0x83,0x83,0x85,0x85,0x85,0x85,0x8b,0x8b,0x8b,0x8b,
    0x90,0x90,0x90,0x90,0x95,0x95,0x95,0x95,0x9b,0x9b,0x9b,0x9b,0xa0,0xa0,0xa0,0xa0,
    0xa5,0xa5,0xa5,0xa5,0xab,0xab,0xab,0xab,0xad,0xad,0xad,0xad,0xa0,0xa0,0xa0,0xa0,
};

static const uint8_t a8r8g8b8_4_4_point_filter_8_8[] =
{
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,
    0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,
    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,
    0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
    0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
    0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,0xb0,
    0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,
    0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
    0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,
    0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
};

static const uint8_t a8r8g8b8_4_4_linear_filter_8_8[] =
{
    0x3c,0x3c,0x3c,0x3c,0x34,0x34,0x34,0x34,0x3c,0x3c,0x3c,0x3c,0x44,0x44,0x44,0x44,
    0x4c,0x4c,0x4c,0x4c,0x54,0x54,0x54,0x54,0x5c,0x5c,0x5c,0x5c,0x54,0x54,0x54,0x54,
    0x1c,0x1c,0x1c,0x1c,0x14,0x14,0x14,0x14,0x1c,0x1c,0x1c,0x1c,0x24,0x24,0x24,0x24,
    0x2c,0x2c,0x2c,0x2c,0x34,0x34,0x34,0x34,0x3c,0x3c,0x3c,0x3c,0x34,0x34,0x34,0x34,
    0x3c,0x3c,0x3c,0x3c,0x34,0x34,0x34,0x34,0x3c,0x3c,0x3c,0x3c,0x44,0x44,0x44,0x44,
    0x4c,0x4c,0x4c,0x4c,0x54,0x54,0x54,0x54,0x5c,0x5c,0x5c,0x5c,0x54,0x54,0x54,0x54,
    0x5c,0x5c,0x5c,0x5c,0x54,0x54,0x54,0x54,0x5c,0x5c,0x5c,0x5c,0x64,0x64,0x64,0x64,
    0x6c,0x6c,0x6c,0x6c,0x74,0x74,0x74,0x74,0x7c,0x7c,0x7c,0x7c,0x74,0x74,0x74,0x74,
    0x7c,0x7c,0x7c,0x7c,0x74,0x74,0x74,0x74,0x7c,0x7c,0x7c,0x7c,0x84,0x84,0x84,0x84,
    0x8c,0x8c,0x8c,0x8c,0x94,0x94,0x94,0x94,0x9c,0x9c,0x9c,0x9c,0x94,0x94,0x94,0x94,
    0x9c,0x9c,0x9c,0x9c,0x94,0x94,0x94,0x94,0x9c,0x9c,0x9c,0x9c,0xa4,0xa4,0xa4,0xa4,
    0xac,0xac,0xac,0xac,0xb4,0xb4,0xb4,0xb4,0xbc,0xbc,0xbc,0xbc,0xb4,0xb4,0xb4,0xb4,
    0xbc,0xbc,0xbc,0xbc,0xb4,0xb4,0xb4,0xb4,0xbc,0xbc,0xbc,0xbc,0xc4,0xc4,0xc4,0xc4,
    0xcc,0xcc,0xcc,0xcc,0xd4,0xd4,0xd4,0xd4,0xdc,0xdc,0xdc,0xdc,0xd4,0xd4,0xd4,0xd4,
    0x9c,0x9c,0x9c,0x9c,0x94,0x94,0x94,0x94,0x9c,0x9c,0x9c,0x9c,0xa4,0xa4,0xa4,0xa4,
    0xac,0xac,0xac,0xac,0xb4,0xb4,0xb4,0xb4,0xbc,0xbc,0xbc,0xbc,0xb4,0xb4,0xb4,0xb4,
};

static const uint8_t a8r8g8b8_8_8_8[] =
{
    0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
    0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07,
    0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0b,
    0x0c,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x0f,
    0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,0x12,0x12,0x12,0x12,0x13,0x13,0x13,0x13,
    0x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17,0x17,
    0x18,0x18,0x18,0x18,0x19,0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1b,
    0x1c,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x1f,
    0x20,0x20,0x20,0x20,0x21,0x21,0x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23,0x23,0x23,
    0x24,0x24,0x24,0x24,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27,0x27,
    0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2b,
    0x2c,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x2f,
    0x30,0x30,0x30,0x30,0x31,0x31,0x31,0x31,0x32,0x32,0x32,0x32,0x33,0x33,0x33,0x33,
    0x34,0x34,0x34,0x34,0x35,0x35,0x35,0x35,0x36,0x36,0x36,0x36,0x37,0x37,0x37,0x37,
    0x38,0x38,0x38,0x38,0x39,0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3b,
    0x3c,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x3f,
    0x40,0x40,0x40,0x40,0x41,0x41,0x41,0x41,0x42,0x42,0x42,0x42,0x43,0x43,0x43,0x43,
    0x44,0x44,0x44,0x44,0x45,0x45,0x45,0x45,0x46,0x46,0x46,0x46,0x47,0x47,0x47,0x47,
    0x48,0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4b,
    0x4c,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x4f,
    0x50,0x50,0x50,0x50,0x51,0x51,0x51,0x51,0x52,0x52,0x52,0x52,0x53,0x53,0x53,0x53,
    0x54,0x54,0x54,0x54,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,0x57,0x57,0x57,0x57,
    0x58,0x58,0x58,0x58,0x59,0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5b,
    0x5c,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x5f,
    0x60,0x60,0x60,0x60,0x61,0x61,0x61,0x61,0x62,0x62,0x62,0x62,0x63,0x63,0x63,0x63,
    0x64,0x64,0x64,0x64,0x65,0x65,0x65,0x65,0x66,0x66,0x66,0x66,0x67,0x67,0x67,0x67,
    0x68,0x68,0x68,0x68,0x69,0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6b,
    0x6c,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x6f,
    0x70,0x70,0x70,0x70,0x71,0x71,0x71,0x71,0x72,0x72,0x72,0x72,0x73,0x73,0x73,0x73,
    0x74,0x74,0x74,0x74,0x75,0x75,0x75,0x75,0x76,0x76,0x76,0x76,0x77,0x77,0x77,0x77,
    0x78,0x78,0x78,0x78,0x79,0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7b,
    0x7c,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,
    0x80,0x80,0x80,0x80,0x81,0x81,0x81,0x81,0x82,0x82,0x82,0x82,0x83,0x83,0x83,0x83,
    0x84,0x84,0x84,0x84,0x85,0x85,0x85,0x85,0x86,0x86,0x86,0x86,0x87,0x87,0x87,0x87,
    0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,0x8a,0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x8b,
    0x8c,0x8c,0x8c,0x8c,0x8d,0x8d,0x8d,0x8d,0x8e,0x8e,0x8e,0x8e,0x8f,0x8f,0x8f,0x8f,
    0x90,0x90,0x90,0x90,0x91,0x91,0x91,0x91,0x92,0x92,0x92,0x92,0x93,0x93,0x93,0x93,
    0x94,0x94,0x94,0x94,0x95,0x95,0x95,0x95,0x96,0x96,0x96,0x96,0x97,0x97,0x97,0x97,
    0x98,0x98,0x98,0x98,0x99,0x99,0x99,0x99,0x9a,0x9a,0x9a,0x9a,0x9b,0x9b,0x9b,0x9b,
    0x9c,0x9c,0x9c,0x9c,0x9d,0x9d,0x9d,0x9d,0x9e,0x9e,0x9e,0x9e,0x9f,0x9f,0x9f,0x9f,
    0xa0,0xa0,0xa0,0xa0,0xa1,0xa1,0xa1,0xa1,0xa2,0xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa3,
    0xa4,0xa4,0xa4,0xa4,0xa5,0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa6,0xa7,0xa7,0xa7,0xa7,
    0xa8,0xa8,0xa8,0xa8,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,0xaa,0xaa,0xab,0xab,0xab,0xab,
    0xac,0xac,0xac,0xac,0xad,0xad,0xad,0xad,0xae,0xae,0xae,0xae,0xaf,0xaf,0xaf,0xaf,
    0xb0,0xb0,0xb0,0xb0,0xb1,0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb2,0xb3,0xb3,0xb3,0xb3,
    0xb4,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb5,0xb6,0xb6,0xb6,0xb6,0xb7,0xb7,0xb7,0xb7,
    0xb8,0xb8,0xb8,0xb8,0xb9,0xb9,0xb9,0xb9,0xba,0xba,0xba,0xba,0xbb,0xbb,0xbb,0xbb,
    0xbc,0xbc,0xbc,0xbc,0xbd,0xbd,0xbd,0xbd,0xbe,0xbe,0xbe,0xbe,0xbf,0xbf,0xbf,0xbf,
    0xc0,0xc0,0xc0,0xc0,0xc1,0xc1,0xc1,0xc1,0xc2,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3,0xc3,
    0xc4,0xc4,0xc4,0xc4,0xc5,0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xc6,0xc7,0xc7,0xc7,0xc7,
    0xc8,0xc8,0xc8,0xc8,0xc9,0xc9,0xc9,0xc9,0xca,0xca,0xca,0xca,0xcb,0xcb,0xcb,0xcb,
    0xcc,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xcd,0xce,0xce,0xce,0xce,0xcf,0xcf,0xcf,0xcf,
    0xd0,0xd0,0xd0,0xd0,0xd1,0xd1,0xd1,0xd1,0xd2,0xd2,0xd2,0xd2,0xd3,0xd3,0xd3,0xd3,
    0xd4,0xd4,0xd4,0xd4,0xd5,0xd5,0xd5,0xd5,0xd6,0xd6,0xd6,0xd6,0xd7,0xd7,0xd7,0xd7,
    0xd8,0xd8,0xd8,0xd8,0xd9,0xd9,0xd9,0xd9,0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,
    0xdc,0xdc,0xdc,0xdc,0xdd,0xdd,0xdd,0xdd,0xde,0xde,0xde,0xde,0xdf,0xdf,0xdf,0xdf,
    0xe0,0xe0,0xe0,0xe0,0xe1,0xe1,0xe1,0xe1,0xe2,0xe2,0xe2,0xe2,0xe3,0xe3,0xe3,0xe3,
    0xe4,0xe4,0xe4,0xe4,0xe5,0xe5,0xe5,0xe5,0xe6,0xe6,0xe6,0xe6,0xe7,0xe7,0xe7,0xe7,
    0xe8,0xe8,0xe8,0xe8,0xe9,0xe9,0xe9,0xe9,0xea,0xea,0xea,0xea,0xeb,0xeb,0xeb,0xeb,
    0xec,0xec,0xec,0xec,0xed,0xed,0xed,0xed,0xee,0xee,0xee,0xee,0xef,0xef,0xef,0xef,
    0xf0,0xf0,0xf0,0xf0,0xf1,0xf1,0xf1,0xf1,0xf2,0xf2,0xf2,0xf2,0xf3,0xf3,0xf3,0xf3,
    0xf4,0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf6,0xf6,0xf6,0xf6,0xf7,0xf7,0xf7,0xf7,
    0xf8,0xf8,0xf8,0xf8,0xf9,0xf9,0xf9,0xf9,0xfa,0xfa,0xfa,0xfa,0xfb,0xfb,0xfb,0xfb,
    0xfc,0xfc,0xfc,0xfc,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff,
    0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
    0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07,
    0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0b,
    0x0c,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x0f,
    0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,0x12,0x12,0x12,0x12,0x13,0x13,0x13,0x13,
    0x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17,0x17,
    0x18,0x18,0x18,0x18,0x19,0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1b,
    0x1c,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x1f,
    0x20,0x20,0x20,0x20,0x21,0x21,0x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23,0x23,0x23,
    0x24,0x24,0x24,0x24,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27,0x27,
    0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2b,
    0x2c,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x2f,
    0x30,0x30,0x30,0x30,0x31,0x31,0x31,0x31,0x32,0x32,0x32,0x32,0x33,0x33,0x33,0x33,
    0x34,0x34,0x34,0x34,0x35,0x35,0x35,0x35,0x36,0x36,0x36,0x36,0x37,0x37,0x37,0x37,
    0x38,0x38,0x38,0x38,0x39,0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3b,
    0x3c,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x3f,
    0x40,0x40,0x40,0x40,0x41,0x41,0x41,0x41,0x42,0x42,0x42,0x42,0x43,0x43,0x43,0x43,
    0x44,0x44,0x44,0x44,0x45,0x45,0x45,0x45,0x46,0x46,0x46,0x46,0x47,0x47,0x47,0x47,
    0x48,0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4b,
    0x4c,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x4f,
    0x50,0x50,0x50,0x50,0x51,0x51,0x51,0x51,0x52,0x52,0x52,0x52,0x53,0x53,0x53,0x53,
    0x54,0x54,0x54,0x54,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,0x57,0x57,0x57,0x57,
    0x58,0x58,0x58,0x58,0x59,0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5b,
    0x5c,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x5f,
    0x60,0x60,0x60,0x60,0x61,0x61,0x61,0x61,0x62,0x62,0x62,0x62,0x63,0x63,0x63,0x63,
    0x64,0x64,0x64,0x64,0x65,0x65,0x65,0x65,0x66,0x66,0x66,0x66,0x67,0x67,0x67,0x67,
    0x68,0x68,0x68,0x68,0x69,0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6b,
    0x6c,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x6f,
    0x70,0x70,0x70,0x70,0x71,0x71,0x71,0x71,0x72,0x72,0x72,0x72,0x73,0x73,0x73,0x73,
    0x74,0x74,0x74,0x74,0x75,0x75,0x75,0x75,0x76,0x76,0x76,0x76,0x77,0x77,0x77,0x77,
    0x78,0x78,0x78,0x78,0x79,0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7b,
    0x7c,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,
    0x80,0x80,0x80,0x80,0x81,0x81,0x81,0x81,0x82,0x82,0x82,0x82,0x83,0x83,0x83,0x83,
    0x84,0x84,0x84,0x84,0x85,0x85,0x85,0x85,0x86,0x86,0x86,0x86,0x87,0x87,0x87,0x87,
    0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,0x8a,0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x8b,
    0x8c,0x8c,0x8c,0x8c,0x8d,0x8d,0x8d,0x8d,0x8e,0x8e,0x8e,0x8e,0x8f,0x8f,0x8f,0x8f,
    0x90,0x90,0x90,0x90,0x91,0x91,0x91,0x91,0x92,0x92,0x92,0x92,0x93,0x93,0x93,0x93,
    0x94,0x94,0x94,0x94,0x95,0x95,0x95,0x95,0x96,0x96,0x96,0x96,0x97,0x97,0x97,0x97,
    0x98,0x98,0x98,0x98,0x99,0x99,0x99,0x99,0x9a,0x9a,0x9a,0x9a,0x9b,0x9b,0x9b,0x9b,
    0x9c,0x9c,0x9c,0x9c,0x9d,0x9d,0x9d,0x9d,0x9e,0x9e,0x9e,0x9e,0x9f,0x9f,0x9f,0x9f,
    0xa0,0xa0,0xa0,0xa0,0xa1,0xa1,0xa1,0xa1,0xa2,0xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa3,
    0xa4,0xa4,0xa4,0xa4,0xa5,0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa6,0xa7,0xa7,0xa7,0xa7,
    0xa8,0xa8,0xa8,0xa8,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,0xaa,0xaa,0xab,0xab,0xab,0xab,
    0xac,0xac,0xac,0xac,0xad,0xad,0xad,0xad,0xae,0xae,0xae,0xae,0xaf,0xaf,0xaf,0xaf,
    0xb0,0xb0,0xb0,0xb0,0xb1,0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb2,0xb3,0xb3,0xb3,0xb3,
    0xb4,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb5,0xb6,0xb6,0xb6,0xb6,0xb7,0xb7,0xb7,0xb7,
    0xb8,0xb8,0xb8,0xb8,0xb9,0xb9,0xb9,0xb9,0xba,0xba,0xba,0xba,0xbb,0xbb,0xbb,0xbb,
    0xbc,0xbc,0xbc,0xbc,0xbd,0xbd,0xbd,0xbd,0xbe,0xbe,0xbe,0xbe,0xbf,0xbf,0xbf,0xbf,
    0xc0,0xc0,0xc0,0xc0,0xc1,0xc1,0xc1,0xc1,0xc2,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3,0xc3,
    0xc4,0xc4,0xc4,0xc4,0xc5,0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xc6,0xc7,0xc7,0xc7,0xc7,
    0xc8,0xc8,0xc8,0xc8,0xc9,0xc9,0xc9,0xc9,0xca,0xca,0xca,0xca,0xcb,0xcb,0xcb,0xcb,
    0xcc,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xcd,0xce,0xce,0xce,0xce,0xcf,0xcf,0xcf,0xcf,
    0xd0,0xd0,0xd0,0xd0,0xd1,0xd1,0xd1,0xd1,0xd2,0xd2,0xd2,0xd2,0xd3,0xd3,0xd3,0xd3,
    0xd4,0xd4,0xd4,0xd4,0xd5,0xd5,0xd5,0xd5,0xd6,0xd6,0xd6,0xd6,0xd7,0xd7,0xd7,0xd7,
    0xd8,0xd8,0xd8,0xd8,0xd9,0xd9,0xd9,0xd9,0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,
    0xdc,0xdc,0xdc,0xdc,0xdd,0xdd,0xdd,0xdd,0xde,0xde,0xde,0xde,0xdf,0xdf,0xdf,0xdf,
    0xe0,0xe0,0xe0,0xe0,0xe1,0xe1,0xe1,0xe1,0xe2,0xe2,0xe2,0xe2,0xe3,0xe3,0xe3,0xe3,
    0xe4,0xe4,0xe4,0xe4,0xe5,0xe5,0xe5,0xe5,0xe6,0xe6,0xe6,0xe6,0xe7,0xe7,0xe7,0xe7,
    0xe8,0xe8,0xe8,0xe8,0xe9,0xe9,0xe9,0xe9,0xea,0xea,0xea,0xea,0xeb,0xeb,0xeb,0xeb,
    0xec,0xec,0xec,0xec,0xed,0xed,0xed,0xed,0xee,0xee,0xee,0xee,0xef,0xef,0xef,0xef,
    0xf0,0xf0,0xf0,0xf0,0xf1,0xf1,0xf1,0xf1,0xf2,0xf2,0xf2,0xf2,0xf3,0xf3,0xf3,0xf3,
    0xf4,0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf6,0xf6,0xf6,0xf6,0xf7,0xf7,0xf7,0xf7,
    0xf8,0xf8,0xf8,0xf8,0xf9,0xf9,0xf9,0xf9,0xfa,0xfa,0xfa,0xfa,0xfb,0xfb,0xfb,0xfb,
    0xfc,0xfc,0xfc,0xfc,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff,
};

static const uint8_t a8r8g8b8_8_8_8_point_filter_4_4_4[] =
{
    0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x06,0x06,0x06,0x06,
    0x10,0x10,0x10,0x10,0x12,0x12,0x12,0x12,0x14,0x14,0x14,0x14,0x16,0x16,0x16,0x16,
    0x20,0x20,0x20,0x20,0x22,0x22,0x22,0x22,0x24,0x24,0x24,0x24,0x26,0x26,0x26,0x26,
    0x30,0x30,0x30,0x30,0x32,0x32,0x32,0x32,0x34,0x34,0x34,0x34,0x36,0x36,0x36,0x36,
    0x80,0x80,0x80,0x80,0x82,0x82,0x82,0x82,0x84,0x84,0x84,0x84,0x86,0x86,0x86,0x86,
    0x90,0x90,0x90,0x90,0x92,0x92,0x92,0x92,0x94,0x94,0x94,0x94,0x96,0x96,0x96,0x96,
    0xa0,0xa0,0xa0,0xa0,0xa2,0xa2,0xa2,0xa2,0xa4,0xa4,0xa4,0xa4,0xa6,0xa6,0xa6,0xa6,
    0xb0,0xb0,0xb0,0xb0,0xb2,0xb2,0xb2,0xb2,0xb4,0xb4,0xb4,0xb4,0xb6,0xb6,0xb6,0xb6,
    0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x06,0x06,0x06,0x06,
    0x10,0x10,0x10,0x10,0x12,0x12,0x12,0x12,0x14,0x14,0x14,0x14,0x16,0x16,0x16,0x16,
    0x20,0x20,0x20,0x20,0x22,0x22,0x22,0x22,0x24,0x24,0x24,0x24,0x26,0x26,0x26,0x26,
    0x30,0x30,0x30,0x30,0x32,0x32,0x32,0x32,0x34,0x34,0x34,0x34,0x36,0x36,0x36,0x36,
    0x80,0x80,0x80,0x80,0x82,0x82,0x82,0x82,0x84,0x84,0x84,0x84,0x86,0x86,0x86,0x86,
    0x90,0x90,0x90,0x90,0x92,0x92,0x92,0x92,0x94,0x94,0x94,0x94,0x96,0x96,0x96,0x96,
    0xa0,0xa0,0xa0,0xa0,0xa2,0xa2,0xa2,0xa2,0xa4,0xa4,0xa4,0xa4,0xa6,0xa6,0xa6,0xa6,
    0xb0,0xb0,0xb0,0xb0,0xb2,0xb2,0xb2,0xb2,0xb4,0xb4,0xb4,0xb4,0xb6,0xb6,0xb6,0xb6,
};

static const uint8_t a8r8g8b8_8_8_8_linear_filter_4_4_4[] =
{
    0x25,0x25,0x25,0x25,0x27,0x27,0x27,0x27,0x29,0x29,0x29,0x29,0x2b,0x2b,0x2b,0x2b,
    0x35,0x35,0x35,0x35,0x37,0x37,0x37,0x37,0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,
    0x45,0x45,0x45,0x45,0x47,0x47,0x47,0x47,0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,
    0x55,0x55,0x55,0x55,0x57,0x57,0x57,0x57,0x59,0x59,0x59,0x59,0x5b,0x5b,0x5b,0x5b,
    0xa5,0xa5,0xa5,0xa5,0xa7,0xa7,0xa7,0xa7,0xa9,0xa9,0xa9,0xa9,0xab,0xab,0xab,0xab,
    0xb5,0xb5,0xb5,0xb5,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xbb,0xbb,0xbb,0xbb,
    0xc5,0xc5,0xc5,0xc5,0xc7,0xc7,0xc7,0xc7,0xc9,0xc9,0xc9,0xc9,0xcb,0xcb,0xcb,0xcb,
    0xd5,0xd5,0xd5,0xd5,0xd7,0xd7,0xd7,0xd7,0xd9,0xd9,0xd9,0xd9,0xdb,0xdb,0xdb,0xdb,
    0x25,0x25,0x25,0x25,0x27,0x27,0x27,0x27,0x29,0x29,0x29,0x29,0x2b,0x2b,0x2b,0x2b,
    0x35,0x35,0x35,0x35,0x37,0x37,0x37,0x37,0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,
    0x45,0x45,0x45,0x45,0x47,0x47,0x47,0x47,0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,
    0x55,0x55,0x55,0x55,0x57,0x57,0x57,0x57,0x59,0x59,0x59,0x59,0x5b,0x5b,0x5b,0x5b,
    0xa5,0xa5,0xa5,0xa5,0xa7,0xa7,0xa7,0xa7,0xa9,0xa9,0xa9,0xa9,0xab,0xab,0xab,0xab,
    0xb5,0xb5,0xb5,0xb5,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xbb,0xbb,0xbb,0xbb,
    0xc5,0xc5,0xc5,0xc5,0xc7,0xc7,0xc7,0xc7,0xc9,0xc9,0xc9,0xc9,0xcb,0xcb,0xcb,0xcb,
    0xd5,0xd5,0xd5,0xd5,0xd7,0xd7,0xd7,0xd7,0xd9,0xd9,0xd9,0xd9,0xdb,0xdb,0xdb,0xdb,
};

static const uint8_t a8r8g8b8_8_8_8_triangle_filter_4_4_4[] =
{
    0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,
    0x45,0x45,0x45,0x45,0x46,0x46,0x46,0x46,0x48,0x48,0x48,0x48,0x4a,0x4a,0x4a,0x4a,
    0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,0x58,0x58,0x58,0x58,0x5a,0x5a,0x5a,0x5a,
    0x61,0x61,0x61,0x61,0x62,0x62,0x62,0x62,0x64,0x64,0x64,0x64,0x66,0x66,0x66,0x66,
    0x99,0x99,0x99,0x99,0x9b,0x9b,0x9b,0x9b,0x9d,0x9d,0x9d,0x9d,0x9e,0x9e,0x9e,0x9e,
    0xa5,0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa6,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,0xaa,0xaa,
    0xb5,0xb5,0xb5,0xb5,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xba,0xba,0xba,0xba,
    0xc1,0xc1,0xc1,0xc1,0xc3,0xc3,0xc3,0xc3,0xc5,0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xc6,
    0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,
    0x45,0x45,0x45,0x45,0x46,0x46,0x46,0x46,0x48,0x48,0x48,0x48,0x4a,0x4a,0x4a,0x4a,
    0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,0x59,0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5a,
    0x61,0x61,0x61,0x61,0x63,0x63,0x63,0x63,0x64,0x64,0x64,0x64,0x66,0x66,0x66,0x66,
    0x99,0x99,0x99,0x99,0x9b,0x9b,0x9b,0x9b,0x9d,0x9d,0x9d,0x9d,0x9e,0x9e,0x9e,0x9e,
    0xa5,0xa5,0xa5,0xa5,0xa7,0xa7,0xa7,0xa7,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,0xaa,0xaa,
    0xb5,0xb5,0xb5,0xb5,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xba,0xba,0xba,0xba,
    0xc1,0xc1,0xc1,0xc1,0xc3,0xc3,0xc3,0xc3,0xc4,0xc4,0xc4,0xc4,0xc6,0xc6,0xc6,0xc6,
};

static const uint8_t a8r8g8b8_8_8_8_triangle_filter_4_4_4_32bit[] =
{
    0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,
    0x45,0x45,0x45,0x45,0x46,0x46,0x46,0x46,0x48,0x48,0x48,0x48,0x4a,0x4a,0x4a,0x4a,
    0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,0x58,0x58,0x58,0x58,0x5a,0x5a,0x5a,0x5a,
    0x61,0x61,0x61,0x61,0x62,0x62,0x62,0x62,0x64,0x64,0x64,0x64,0x66,0x66,0x66,0x66,
    0x99,0x99,0x99,0x99,0x9b,0x9b,0x9b,0x9b,0x9d,0x9d,0x9d,0x9d,0x9e,0x9e,0x9e,0x9e,
    0xa5,0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa6,0xa8,0xa8,0xa8,0xa8,0xaa,0xaa,0xaa,0xaa,
    0xb5,0xb5,0xb5,0xb5,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xba,0xba,0xba,0xba,
    0xc1,0xc1,0xc1,0xc1,0xc3,0xc3,0xc3,0xc3,0xc4,0xc4,0xc4,0xc4,0xc6,0xc6,0xc6,0xc6,
    0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,0x3d,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3e,
    0x45,0x45,0x45,0x45,0x46,0x46,0x46,0x46,0x48,0x48,0x48,0x48,0x4a,0x4a,0x4a,0x4a,
    0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,0x59,0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5a,
    0x61,0x61,0x61,0x61,0x63,0x63,0x63,0x63,0x64,0x64,0x64,0x64,0x66,0x66,0x66,0x66,
    0x99,0x99,0x99,0x99,0x9b,0x9b,0x9b,0x9b,0x9d,0x9d,0x9d,0x9d,0x9e,0x9e,0x9e,0x9e,
    0xa5,0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa6,0xa9,0xa9,0xa9,0xa9,0xaa,0xaa,0xaa,0xaa,
    0xb5,0xb5,0xb5,0xb5,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xba,0xba,0xba,0xba,
    0xc1,0xc1,0xc1,0xc1,0xc3,0xc3,0xc3,0xc3,0xc4,0xc4,0xc4,0xc4,0xc6,0xc6,0xc6,0xc6,
};

static const uint8_t a8r8g8b8_8_8_8_box_filter_4_4_4_32bit[] =
{
    0x25,0x25,0x25,0x25,0x27,0x27,0x27,0x27,0x29,0x29,0x29,0x29,0x2b,0x2b,0x2b,0x2b,
    0x35,0x35,0x35,0x35,0x37,0x37,0x37,0x37,0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,
    0x45,0x45,0x45,0x45,0x47,0x47,0x47,0x47,0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,
    0x55,0x55,0x55,0x55,0x57,0x57,0x57,0x57,0x59,0x59,0x59,0x59,0x5b,0x5b,0x5b,0x5b,
    0xa4,0xa4,0xa4,0xa4,0xa7,0xa7,0xa7,0xa7,0xa9,0xa9,0xa9,0xa9,0xab,0xab,0xab,0xab,
    0xb4,0xb4,0xb4,0xb4,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xbb,0xbb,0xbb,0xbb,
    0xc5,0xc5,0xc5,0xc5,0xc7,0xc7,0xc7,0xc7,0xc9,0xc9,0xc9,0xc9,0xcb,0xcb,0xcb,0xcb,
    0xd5,0xd5,0xd5,0xd5,0xd7,0xd7,0xd7,0xd7,0xd9,0xd9,0xd9,0xd9,0xdb,0xdb,0xdb,0xdb,
    0x25,0x25,0x25,0x25,0x27,0x27,0x27,0x27,0x29,0x29,0x29,0x29,0x2b,0x2b,0x2b,0x2b,
    0x35,0x35,0x35,0x35,0x37,0x37,0x37,0x37,0x39,0x39,0x39,0x39,0x3b,0x3b,0x3b,0x3b,
    0x45,0x45,0x45,0x45,0x47,0x47,0x47,0x47,0x49,0x49,0x49,0x49,0x4b,0x4b,0x4b,0x4b,
    0x55,0x55,0x55,0x55,0x57,0x57,0x57,0x57,0x59,0x59,0x59,0x59,0x5b,0x5b,0x5b,0x5b,
    0xa4,0xa4,0xa4,0xa4,0xa7,0xa7,0xa7,0xa7,0xa9,0xa9,0xa9,0xa9,0xab,0xab,0xab,0xab,
    0xb4,0xb4,0xb4,0xb4,0xb7,0xb7,0xb7,0xb7,0xb9,0xb9,0xb9,0xb9,0xbb,0xbb,0xbb,0xbb,
    0xc5,0xc5,0xc5,0xc5,0xc7,0xc7,0xc7,0xc7,0xc9,0xc9,0xc9,0xc9,0xcb,0xcb,0xcb,0xcb,
    0xd5,0xd5,0xd5,0xd5,0xd7,0xd7,0xd7,0xd7,0xd9,0xd9,0xd9,0xd9,0xdb,0xdb,0xdb,0xdb,
};

static const uint8_t a8r8g8b8_6_6_6[] =
{
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x18,0x18,0x24,0x24,0x24,0x24,
    0x30,0x30,0x30,0x30,0x3c,0x3c,0x3c,0x3c,0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,
    0x40,0x40,0x40,0x40,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,0x64,0x64,0x64,0x64,
    0x50,0x50,0x50,0x50,0x5c,0x5c,0x5c,0x5c,0x68,0x68,0x68,0x68,0x74,0x74,0x74,0x74,
    0x80,0x80,0x80,0x80,0x8c,0x8c,0x8c,0x8c,0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,
    0x90,0x90,0x90,0x90,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,0xb4,0xb4,0xb4,0xb4,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xb8,0xb8,0xb8,0xb8,0xc4,0xc4,0xc4,0xc4,
    0xd0,0xd0,0xd0,0xd0,0xdc,0xdc,0xdc,0xdc,0xc8,0xc8,0xc8,0xc8,0xd4,0xd4,0xd4,0xd4,
    0xe0,0xe0,0xe0,0xe0,0xec,0xec,0xec,0xec,0xf8,0xf8,0xf8,0xf8,0xff,0xff,0xff,0xff,
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x18,0x18,0x24,0x24,0x24,0x24,
    0x30,0x30,0x30,0x30,0x3c,0x3c,0x3c,0x3c,0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,
    0x40,0x40,0x40,0x40,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,0x64,0x64,0x64,0x64,
    0x50,0x50,0x50,0x50,0x5c,0x5c,0x5c,0x5c,0x68,0x68,0x68,0x68,0x74,0x74,0x74,0x74,
    0x80,0x80,0x80,0x80,0x8c,0x8c,0x8c,0x8c,0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,
    0x90,0x90,0x90,0x90,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,0xb4,0xb4,0xb4,0xb4,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xb8,0xb8,0xb8,0xb8,0xc4,0xc4,0xc4,0xc4,
    0xd0,0xd0,0xd0,0xd0,0xdc,0xdc,0xdc,0xdc,0xc8,0xc8,0xc8,0xc8,0xd4,0xd4,0xd4,0xd4,
    0xe0,0xe0,0xe0,0xe0,0xec,0xec,0xec,0xec,0xf8,0xf8,0xf8,0xf8,0xff,0xff,0xff,0xff,
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x18,0x18,0x24,0x24,0x24,0x24,
    0x30,0x30,0x30,0x30,0x3c,0x3c,0x3c,0x3c,0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,
    0x40,0x40,0x40,0x40,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,0x64,0x64,0x64,0x64,
    0x50,0x50,0x50,0x50,0x5c,0x5c,0x5c,0x5c,0x68,0x68,0x68,0x68,0x74,0x74,0x74,0x74,
    0x80,0x80,0x80,0x80,0x8c,0x8c,0x8c,0x8c,0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,
    0x90,0x90,0x90,0x90,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,0xb4,0xb4,0xb4,0xb4,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xb8,0xb8,0xb8,0xb8,0xc4,0xc4,0xc4,0xc4,
    0xd0,0xd0,0xd0,0xd0,0xdc,0xdc,0xdc,0xdc,0xc8,0xc8,0xc8,0xc8,0xd4,0xd4,0xd4,0xd4,
    0xe0,0xe0,0xe0,0xe0,0xec,0xec,0xec,0xec,0xf8,0xf8,0xf8,0xf8,0xff,0xff,0xff,0xff,
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x18,0x18,0x24,0x24,0x24,0x24,
    0x30,0x30,0x30,0x30,0x3c,0x3c,0x3c,0x3c,0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,
    0x40,0x40,0x40,0x40,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,0x64,0x64,0x64,0x64,
    0x50,0x50,0x50,0x50,0x5c,0x5c,0x5c,0x5c,0x68,0x68,0x68,0x68,0x74,0x74,0x74,0x74,
    0x80,0x80,0x80,0x80,0x8c,0x8c,0x8c,0x8c,0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,
    0x90,0x90,0x90,0x90,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,0xb4,0xb4,0xb4,0xb4,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xb8,0xb8,0xb8,0xb8,0xc4,0xc4,0xc4,0xc4,
    0xd0,0xd0,0xd0,0xd0,0xdc,0xdc,0xdc,0xdc,0xc8,0xc8,0xc8,0xc8,0xd4,0xd4,0xd4,0xd4,
    0xe0,0xe0,0xe0,0xe0,0xec,0xec,0xec,0xec,0xf8,0xf8,0xf8,0xf8,0xff,0xff,0xff,0xff,
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x18,0x18,0x24,0x24,0x24,0x24,
    0x30,0x30,0x30,0x30,0x3c,0x3c,0x3c,0x3c,0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,
    0x40,0x40,0x40,0x40,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,0x64,0x64,0x64,0x64,
    0x50,0x50,0x50,0x50,0x5c,0x5c,0x5c,0x5c,0x68,0x68,0x68,0x68,0x74,0x74,0x74,0x74,
    0x80,0x80,0x80,0x80,0x8c,0x8c,0x8c,0x8c,0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,
    0x90,0x90,0x90,0x90,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,0xb4,0xb4,0xb4,0xb4,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xb8,0xb8,0xb8,0xb8,0xc4,0xc4,0xc4,0xc4,
    0xd0,0xd0,0xd0,0xd0,0xdc,0xdc,0xdc,0xdc,0xc8,0xc8,0xc8,0xc8,0xd4,0xd4,0xd4,0xd4,
    0xe0,0xe0,0xe0,0xe0,0xec,0xec,0xec,0xec,0xf8,0xf8,0xf8,0xf8,0xff,0xff,0xff,0xff,
    0x00,0x00,0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x18,0x18,0x24,0x24,0x24,0x24,
    0x30,0x30,0x30,0x30,0x3c,0x3c,0x3c,0x3c,0x28,0x28,0x28,0x28,0x34,0x34,0x34,0x34,
    0x40,0x40,0x40,0x40,0x4c,0x4c,0x4c,0x4c,0x58,0x58,0x58,0x58,0x64,0x64,0x64,0x64,
    0x50,0x50,0x50,0x50,0x5c,0x5c,0x5c,0x5c,0x68,0x68,0x68,0x68,0x74,0x74,0x74,0x74,
    0x80,0x80,0x80,0x80,0x8c,0x8c,0x8c,0x8c,0x78,0x78,0x78,0x78,0x84,0x84,0x84,0x84,
    0x90,0x90,0x90,0x90,0x9c,0x9c,0x9c,0x9c,0xa8,0xa8,0xa8,0xa8,0xb4,0xb4,0xb4,0xb4,
    0xa0,0xa0,0xa0,0xa0,0xac,0xac,0xac,0xac,0xb8,0xb8,0xb8,0xb8,0xc4,0xc4,0xc4,0xc4,
    0xd0,0xd0,0xd0,0xd0,0xdc,0xdc,0xdc,0xdc,0xc8,0xc8,0xc8,0xc8,0xd4,0xd4,0xd4,0xd4,
    0xe0,0xe0,0xe0,0xe0,0xec,0xec,0xec,0xec,0xf8,0xf8,0xf8,0xf8,0xff,0xff,0xff,0xff,
};

static const uint8_t a8r8g8b8_6_6_6_point_filter_3_3_3[] =
{
    0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x30,0x30,0x30,0x30,0x50,0x50,0x50,0x50,
    0x68,0x68,0x68,0x68,0x80,0x80,0x80,0x80,0xa0,0xa0,0xa0,0xa0,0xb8,0xb8,0xb8,0xb8,
    0xd0,0xd0,0xd0,0xd0,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x30,0x30,0x30,0x30,
    0x50,0x50,0x50,0x50,0x68,0x68,0x68,0x68,0x80,0x80,0x80,0x80,0xa0,0xa0,0xa0,0xa0,
    0xb8,0xb8,0xb8,0xb8,0xd0,0xd0,0xd0,0xd0,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,
    0x30,0x30,0x30,0x30,0x50,0x50,0x50,0x50,0x68,0x68,0x68,0x68,0x80,0x80,0x80,0x80,
    0xa0,0xa0,0xa0,0xa0,0xb8,0xb8,0xb8,0xb8,0xd0,0xd0,0xd0,0xd0,
};

static const uint8_t a8r8g8b8_6_6_6_linear_filter_3_3_3[] =
{
    0x1a,0x1a,0x1a,0x1a,0x32,0x32,0x32,0x32,0x4a,0x4a,0x4a,0x4a,0x6a,0x6a,0x6a,0x6a,
    0x82,0x82,0x82,0x82,0x9a,0x9a,0x9a,0x9a,0xba,0xba,0xba,0xba,0xd2,0xd2,0xd2,0xd2,
    0xe9,0xe9,0xe9,0xe9,0x1a,0x1a,0x1a,0x1a,0x32,0x32,0x32,0x32,0x4a,0x4a,0x4a,0x4a,
    0x6a,0x6a,0x6a,0x6a,0x82,0x82,0x82,0x82,0x9a,0x9a,0x9a,0x9a,0xba,0xba,0xba,0xba,
    0xd2,0xd2,0xd2,0xd2,0xe9,0xe9,0xe9,0xe9,0x1a,0x1a,0x1a,0x1a,0x32,0x32,0x32,0x32,
    0x4a,0x4a,0x4a,0x4a,0x6a,0x6a,0x6a,0x6a,0x82,0x82,0x82,0x82,0x9a,0x9a,0x9a,0x9a,
    0xba,0xba,0xba,0xba,0xd2,0xd2,0xd2,0xd2,0xe9,0xe9,0xe9,0xe9,
};

static const uint8_t a8r8g8b8_6_6_6_triangle_filter_3_3_3[] =
{
    0x2d,0x2d,0x2d,0x2d,0x41,0x41,0x41,0x41,0x54,0x54,0x54,0x54,0x6f,0x6f,0x6f,0x6f,
    0x82,0x82,0x82,0x82,0x96,0x96,0x96,0x96,0xaf,0xaf,0xaf,0xaf,0xc3,0xc3,0xc3,0xc3,
    0xd6,0xd6,0xd6,0xd6,0x2d,0x2d,0x2d,0x2d,0x41,0x41,0x41,0x41,0x54,0x54,0x54,0x54,
    0x6f,0x6f,0x6f,0x6f,0x82,0x82,0x82,0x82,0x96,0x96,0x96,0x96,0xaf,0xaf,0xaf,0xaf,
    0xc3,0xc3,0xc3,0xc3,0xd6,0xd6,0xd6,0xd6,0x2d,0x2d,0x2d,0x2d,0x41,0x41,0x41,0x41,
    0x54,0x54,0x54,0x54,0x6f,0x6f,0x6f,0x6f,0x82,0x82,0x82,0x82,0x96,0x96,0x96,0x96,
    0xaf,0xaf,0xaf,0xaf,0xc3,0xc3,0xc3,0xc3,0xd6,0xd6,0xd6,0xd6,
};

static const uint8_t a8r8g8b8_6_6_6_triangle_dither_filter_3_3_3[] =
{
    0x2e,0x2e,0x2e,0x2e,0x41,0x41,0x41,0x41,0x55,0x55,0x55,0x55,0x6e,0x6e,0x6e,0x6e,
    0x82,0x82,0x82,0x82,0x95,0x95,0x95,0x95,0xb0,0xb0,0xb0,0xb0,0xc3,0xc3,0xc3,0xc3,
    0xd6,0xd6,0xd6,0xd6,0x2d,0x2d,0x2d,0x2d,0x41,0x41,0x41,0x41,0x54,0x54,0x54,0x54,
    0x6f,0x6f,0x6f,0x6f,0x82,0x82,0x82,0x82,0x96,0x96,0x96,0x96,0xaf,0xaf,0xaf,0xaf,
    0xc3,0xc3,0xc3,0xc3,0xd5,0xd5,0xd5,0xd5,0x2e,0x2e,0x2e,0x2e,0x41,0x41,0x41,0x41,
    0x55,0x55,0x55,0x55,0x6e,0x6e,0x6e,0x6e,0x82,0x82,0x82,0x82,0x95,0x95,0x95,0x95,
    0xb0,0xb0,0xb0,0xb0,0xc3,0xc3,0xc3,0xc3,0xd6,0xd6,0xd6,0xd6,
};

static inline const char *debug_d3dformat(D3DFORMAT format_id)
{
    switch (format_id)
    {
#define FMT_TO_STR(format_id) case format_id: return #format_id
    FMT_TO_STR(D3DFMT_UNKNOWN);
    FMT_TO_STR(D3DFMT_R8G8B8);
    FMT_TO_STR(D3DFMT_A8R8G8B8);
    FMT_TO_STR(D3DFMT_X8R8G8B8);
    FMT_TO_STR(D3DFMT_R5G6B5);
    FMT_TO_STR(D3DFMT_X1R5G5B5);
    FMT_TO_STR(D3DFMT_A1R5G5B5);
    FMT_TO_STR(D3DFMT_A4R4G4B4);
    FMT_TO_STR(D3DFMT_R3G3B2);
    FMT_TO_STR(D3DFMT_A8);
    FMT_TO_STR(D3DFMT_A8R3G3B2);
    FMT_TO_STR(D3DFMT_X4R4G4B4);
    FMT_TO_STR(D3DFMT_A2B10G10R10);
    FMT_TO_STR(D3DFMT_A8B8G8R8);
    FMT_TO_STR(D3DFMT_X8B8G8R8);
    FMT_TO_STR(D3DFMT_G16R16);
    FMT_TO_STR(D3DFMT_A2R10G10B10);
    FMT_TO_STR(D3DFMT_A16B16G16R16);
    FMT_TO_STR(D3DFMT_A8P8);
    FMT_TO_STR(D3DFMT_P8);
    FMT_TO_STR(D3DFMT_L8);
    FMT_TO_STR(D3DFMT_A8L8);
    FMT_TO_STR(D3DFMT_A4L4);
    FMT_TO_STR(D3DFMT_V8U8);
    FMT_TO_STR(D3DFMT_L6V5U5);
    FMT_TO_STR(D3DFMT_X8L8V8U8);
    FMT_TO_STR(D3DFMT_Q8W8V8U8);
    FMT_TO_STR(D3DFMT_V16U16);
    FMT_TO_STR(D3DFMT_A2W10V10U10);
    FMT_TO_STR(D3DFMT_UYVY);
    FMT_TO_STR(D3DFMT_YUY2);
    FMT_TO_STR(D3DFMT_DXT1);
    FMT_TO_STR(D3DFMT_DXT2);
    FMT_TO_STR(D3DFMT_DXT3);
    FMT_TO_STR(D3DFMT_DXT4);
    FMT_TO_STR(D3DFMT_DXT5);
    FMT_TO_STR(D3DFMT_MULTI2_ARGB8);
    FMT_TO_STR(D3DFMT_G8R8_G8B8);
    FMT_TO_STR(D3DFMT_R8G8_B8G8);
    FMT_TO_STR(D3DFMT_D16_LOCKABLE);
    FMT_TO_STR(D3DFMT_D32);
    FMT_TO_STR(D3DFMT_D15S1);
    FMT_TO_STR(D3DFMT_D24S8);
    FMT_TO_STR(D3DFMT_D24X8);
    FMT_TO_STR(D3DFMT_D24X4S4);
    FMT_TO_STR(D3DFMT_D16);
    FMT_TO_STR(D3DFMT_L16);
    FMT_TO_STR(D3DFMT_D32F_LOCKABLE);
    FMT_TO_STR(D3DFMT_D24FS8);
    FMT_TO_STR(D3DFMT_D32_LOCKABLE);
    FMT_TO_STR(D3DFMT_S8_LOCKABLE);
    FMT_TO_STR(D3DFMT_VERTEXDATA);
    FMT_TO_STR(D3DFMT_INDEX16);
    FMT_TO_STR(D3DFMT_INDEX32);
    FMT_TO_STR(D3DFMT_Q16W16V16U16);
    FMT_TO_STR(D3DFMT_R16F);
    FMT_TO_STR(D3DFMT_G16R16F);
    FMT_TO_STR(D3DFMT_A16B16G16R16F);
    FMT_TO_STR(D3DFMT_R32F);
    FMT_TO_STR(D3DFMT_G32R32F);
    FMT_TO_STR(D3DFMT_A32B32G32R32F);
    FMT_TO_STR(D3DFMT_CxV8U8);
    FMT_TO_STR(D3DFMT_A1);
    FMT_TO_STR(D3DFMT_A2B10G10R10_XR_BIAS);
    FMT_TO_STR(D3DFMT_BINARYBUFFER);
#undef FMT_TO_STR
    default:
        return "unknown";
    }
}

static inline uint32_t get_bpp_for_d3dformat(D3DFORMAT format)
{
    switch (format)
    {
        case D3DFMT_A32B32G32R32F:
            return 16;

        case D3DFMT_A16B16G16R16:
        case D3DFMT_Q16W16V16U16:
            return 8;

        case D3DFMT_Q8W8V8U8:
        case D3DFMT_A8B8G8R8:
        case D3DFMT_A8R8G8B8:
        case D3DFMT_V16U16:
        case D3DFMT_G16R16:
        case D3DFMT_R32F:
            return 4;

        case D3DFMT_R8G8B8:
            return 3;

        case D3DFMT_A4R4G4B4:
        case D3DFMT_X1R5G5B5:
        case D3DFMT_A1R5G5B5:
        case D3DFMT_R5G6B5:
        case D3DFMT_V8U8:
        case D3DFMT_A8P8:
            return 2;

        case D3DFMT_R3G3B2:
        case D3DFMT_DXT5:
        case D3DFMT_DXT4:
        case D3DFMT_A4L4:
        case D3DFMT_L8:
        case D3DFMT_P8:
            return 1;

        default:
            assert(0 && "Need to add format to get_bpp_for_d3dformat().");
            return 0;
    }
}

#define check_image_info(info, width, height, depth, mip_levels, format, resource_type, image_file_format, wine_todo) \
    check_image_info_(__FILE__, __LINE__, info, width, height, depth, mip_levels, format, resource_type, \
            image_file_format, wine_todo)
static inline void check_image_info_(const char *file, uint32_t line, const D3DXIMAGE_INFO *info, uint32_t width,
        uint32_t height, uint32_t depth, uint32_t mip_levels, D3DFORMAT format, D3DRESOURCETYPE resource_type,
        D3DXIMAGE_FILEFORMAT image_file_format, BOOL wine_todo)
{
    const D3DXIMAGE_INFO expected_info = { width, height, depth, mip_levels, format, resource_type, image_file_format };
    BOOL matched;

    matched = !memcmp(&expected_info, info, sizeof(*info));
    todo_wine_if(wine_todo) ok_(file, line)(matched, "Got unexpected image info values.\n");
    if (matched)
        return;

    todo_wine_if(wine_todo && info->Width != width)
        ok_(file, line)(info->Width == width, "Expected width %u, got %u.\n", width, info->Width);
    todo_wine_if(wine_todo && info->Height != height)
        ok_(file, line)(info->Height == height, "Expected height %u, got %u.\n", height, info->Height);
    todo_wine_if(wine_todo && info->Depth != depth)
        ok_(file, line)(info->Depth == depth, "Expected depth %u, got %u.\n", depth, info->Depth);
    todo_wine_if(wine_todo && info->MipLevels != mip_levels)
        ok_(file, line)(info->MipLevels == mip_levels, "Expected mip_levels %u, got %u.\n", mip_levels,
                info->MipLevels);
    todo_wine_if(wine_todo && info->Format != format)
        ok_(file, line)(info->Format == format, "Expected texture format %s (%u), got %s (%u).\n",
                debug_d3dformat(format), format, debug_d3dformat(info->Format), info->Format);
    todo_wine_if(wine_todo && info->ResourceType != resource_type)
        ok_(file, line)(info->ResourceType == resource_type, "Expected resource_type %d, got %d.\n", resource_type,
                info->ResourceType);
    ok_(file, line)(info->ImageFileFormat == image_file_format, "Expected image_file_format %d, got %d.\n",
            image_file_format, info->ImageFileFormat);
}

#define check_dds_pixel_format_struct(pixel_format, expected_pixel_format, wine_todo) \
    check_dds_pixel_format_struct_(__FILE__, __LINE__, pixel_format, expected_pixel_format, wine_todo)
static inline void check_dds_pixel_format_struct_(const char *file, uint32_t line, const struct dds_pixel_format *pixel_format,
        const struct dds_pixel_format *expected_pixel_format, BOOL wine_todo)
{
    BOOL matched;

    matched = !memcmp(expected_pixel_format, pixel_format, sizeof(*pixel_format));
    todo_wine_if(wine_todo) ok_(file, line)(matched, "Got unexpected dds pixel format values.\n");
    if (matched)
        return;

    todo_wine_if(wine_todo && pixel_format->flags != expected_pixel_format->flags)
        ok_(file, line)(pixel_format->flags == expected_pixel_format->flags, "Unexpected DDS pixel format flags %#lx.\n",
                pixel_format->flags);
    todo_wine_if(wine_todo && pixel_format->fourcc != expected_pixel_format->fourcc)
        ok_(file, line)(pixel_format->fourcc == expected_pixel_format->fourcc, "Unexpected DDS pixel format fourcc %#lx.\n",
                pixel_format->fourcc);
    todo_wine_if(wine_todo && pixel_format->bpp != expected_pixel_format->bpp)
        ok_(file, line)(pixel_format->bpp == expected_pixel_format->bpp, "Unexpected DDS pixel format bpp %#lx.\n",
                pixel_format->bpp);
    todo_wine_if(wine_todo && pixel_format->rmask != expected_pixel_format->rmask)
        ok_(file, line)(pixel_format->rmask == expected_pixel_format->rmask, "Unexpected DDS pixel format rmask %#lx.\n",
                pixel_format->rmask);
    todo_wine_if(wine_todo && pixel_format->gmask != expected_pixel_format->gmask)
        ok_(file, line)(pixel_format->gmask == expected_pixel_format->gmask, "Unexpected DDS pixel format gmask %#lx.\n",
                pixel_format->gmask);
    todo_wine_if(wine_todo && pixel_format->bmask != expected_pixel_format->bmask)
        ok_(file, line)(pixel_format->bmask == expected_pixel_format->bmask, "Unexpected DDS pixel format bmask %#lx.\n",
                pixel_format->bmask);
    todo_wine_if(wine_todo && pixel_format->amask != expected_pixel_format->amask)
        ok_(file, line)(pixel_format->amask == expected_pixel_format->amask, "Unexpected DDS pixel format amask %#lx.\n",
                pixel_format->amask);
}

#define check_dds_header(header, flags, height, width, pitch, depth, mip_levels, pixel_format, caps, caps2, wine_todo) \
    check_dds_header_(__FILE__, __LINE__, header, flags, height, width, pitch, depth, mip_levels, pixel_format, \
                      caps, caps2, wine_todo)
static inline void check_dds_header_(const char *file, uint32_t line, const struct dds_header *header, uint32_t flags,
        uint32_t height, uint32_t width, uint32_t pitch, uint32_t depth, uint32_t mip_levels,
        const struct dds_pixel_format *pixel_format, uint32_t caps, uint32_t caps2, BOOL wine_todo)
{
    const struct dds_header expected_header = { sizeof(*header), flags, height, width, pitch, depth, mip_levels, { 0 },
                                                *pixel_format, caps, caps2, 0, 0, 0 };
    BOOL matched;

    matched = !memcmp(&expected_header, header, sizeof(*header));
    todo_wine_if(wine_todo) ok_(file, line)(matched, "Got unexpected dds header values.\n");
    if (matched)
        return;

    todo_wine_if(wine_todo && header->flags != flags)
        ok_(file, line)(header->flags == flags, "Unexpected DDS header flags %#lx.\n", header->flags);
    todo_wine_if(wine_todo && header->width != width)
        ok_(file, line)(header->width == width, "Unexpected DDS header width %#lx.\n", header->width);
    todo_wine_if(wine_todo && header->height != height)
        ok_(file, line)(header->height == height, "Unexpected DDS header height %#lx.\n", header->height);
    todo_wine_if(wine_todo && header->pitch_or_linear_size != pitch)
        ok_(file, line)(header->pitch_or_linear_size == pitch, "Unexpected DDS header pitch %#lx.\n",
                header->pitch_or_linear_size);
    todo_wine_if(wine_todo && header->depth != depth)
        ok_(file, line)(header->depth == depth, "Unexpected DDS header depth %#lx.\n", header->depth);
    todo_wine_if(wine_todo && header->miplevels != mip_levels)
        ok_(file, line)(header->miplevels == mip_levels, "Unexpected DDS header mip levels %#lx.\n", header->miplevels);
    ok_(file, line)(!memcmp(header->reserved, expected_header.reserved, sizeof(header->reserved)),
            "Unexpected values in DDS header reserved field.");
    check_dds_pixel_format_struct(&header->pixel_format, pixel_format, FALSE);
    todo_wine_if(wine_todo && header->caps != caps)
        ok_(file, line)(header->caps == caps, "Unexpected DDS header caps %#lx.\n", header->caps);
    todo_wine_if(wine_todo && header->caps2 != caps2)
        ok_(file, line)(header->caps2 == caps2, "Unexpected DDS header caps2 %#lx.\n", header->caps2);
    ok_(file, line)(!header->caps3, "Unexpected DDS header caps3 %#lx.\n", header->caps3);
    ok_(file, line)(!header->caps4, "Unexpected DDS header caps4 %#lx.\n", header->caps4);
    ok_(file, line)(!header->reserved2, "Unexpected DDS header reserved2 %#lx.\n", header->reserved2);
}

struct volume_readback
{
    IDirect3DVolume9 *volume;
    D3DLOCKED_BOX locked_box;
};

static inline uint32_t get_volume_readback_color(struct volume_readback *rb, uint32_t x, uint32_t y, uint32_t z)
{
    const uint32_t *pixels = rb->locked_box.pBits;
    const D3DLOCKED_BOX *box = &rb->locked_box;

    if (!box->pBits)
        return 0xdeadbeef;
    return pixels[(z * (box->SlicePitch / sizeof(uint32_t)) + (y * (box->RowPitch / sizeof(uint32_t))) + x)];
}

#define release_volume_readback(rb) release_volume_readback_(__FILE__, __LINE__, rb)
static inline void release_volume_readback_(const char *file, uint32_t line, struct volume_readback *rb)
{
    HRESULT hr;

    if (!rb->volume)
        return;
    if (rb->locked_box.pBits && FAILED(hr = IDirect3DVolume9_UnlockBox(rb->volume)))
        trace_(file, line)("Can't unlock the readback volume, hr %#lx.\n", hr);
    IDirect3DVolume9_Release(rb->volume);
}

#define get_texture_volume_readback(device, volume_tex, mip_level, rb) \
    get_texture_volume_readback_(__FILE__, __LINE__, device, volume_tex, mip_level, rb)
static inline void get_texture_volume_readback_(const char *file, uint32_t line, IDirect3DDevice9 *device,
        IDirect3DVolumeTexture9 *volume_tex, uint32_t mip_level, struct volume_readback *rb)
{
    IDirect3DVolumeTexture9 *rb_tex;
    IDirect3DVolume9 *volume = NULL;
    D3DVOLUME_DESC desc;
    HRESULT hr;

    memset(rb, 0, sizeof(*rb));
    hr = IDirect3DVolumeTexture9_GetLevelDesc(volume_tex, mip_level, &desc);
    if (FAILED(hr))
    {
        trace_(file, line)("Failed to get volume description for mip level %d, hr %#lx.\n", mip_level, hr);
        return;
    }

    hr = IDirect3DDevice9_CreateVolumeTexture(device, desc.Width, desc.Height, desc.Depth, 1, 0, D3DFMT_A8R8G8B8,
            D3DPOOL_SYSTEMMEM, &rb_tex, NULL);
    if (FAILED(hr))
    {
        trace_(file, line)("Can't create the readback volume texture, hr %#lx.\n", hr);
        return;
    }

    hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_tex, mip_level, &volume);
    if (FAILED(hr))
    {
        trace_(file, line)("Failed to get the volume for mip_level %d, hr %#lx.\n", mip_level, hr);
        goto exit;
    }

    hr = IDirect3DVolumeTexture9_GetVolumeLevel(rb_tex, 0, &rb->volume);
    if (FAILED(hr))
    {
        trace_(file, line)("Failed to get readback volume, hr %#lx.\n", hr);
        goto exit;
    }

    hr = D3DXLoadVolumeFromVolume(rb->volume, NULL, NULL, volume, NULL, NULL, D3DX_FILTER_NONE, 0);
    if (FAILED(hr))
    {
        trace_(file, line)("Can't load the source volume into the readback, hr %#lx.\n", hr);
        goto exit;
    }

    hr = IDirect3DVolume9_LockBox(rb->volume, &rb->locked_box, NULL, D3DLOCK_READONLY);
    if (FAILED(hr))
        trace_(file, line)("Can't lock the readback volume, hr %#lx.\n", hr);

exit:
    IDirect3DVolumeTexture9_Release(rb_tex);
    if (volume)
        IDirect3DVolume9_Release(volume);
    if (FAILED(hr))
    {
        if (rb->volume)
            IDirect3DVolume9_Release(rb->volume);
        rb->volume = NULL;
    }
}

static inline void set_box(D3DBOX *box, UINT left, UINT top, UINT right, UINT bottom, UINT front, UINT back)
{
    box->Left = left;
    box->Top = top;
    box->Right = right;
    box->Bottom = bottom;
    box->Front = front;
    box->Back = back;
}

static inline BOOL compare_uint(uint32_t x, uint32_t y, uint32_t max_diff)
{
    uint32_t diff = x > y ? x - y : y - x;

    return diff <= max_diff;
}

static inline BOOL compare_color_4bpp(uint32_t c1, uint32_t c2, uint8_t max_diff)
{
    return compare_uint(c1 & 0xff, c2 & 0xff, max_diff)
            && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff)
            && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff)
            && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff);
}

#define check_volume_readback_pixel_4bpp_diff(rb, x, y, z, color, max_diff, todo) \
    _check_volume_readback_pixel_4bpp_diff(__FILE__, __LINE__, rb, x, y, z, color, max_diff, todo)
static inline void _check_volume_readback_pixel_4bpp_diff(const char *file, uint32_t line, struct volume_readback *rb,
        uint32_t x, uint32_t y, uint32_t z, uint32_t expected_color, uint32_t max_diff, BOOL todo)
{
    uint32_t color = get_volume_readback_color(rb, x, y, z);

    todo_wine_if(todo) ok_(file, line)(compare_color_4bpp(color, expected_color, max_diff),
           "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
}

#define check_volume_readback_pixel_4bpp(rb, x, y, z, color, todo) \
    _check_volume_readback_pixel_4bpp(__FILE__, __LINE__, rb, x, y, z, color, todo)
static inline void _check_volume_readback_pixel_4bpp(const char *file, uint32_t line, struct volume_readback *rb,
        uint32_t x, uint32_t y, uint32_t z, uint32_t expected_color, BOOL todo)
{
   uint32_t color = get_volume_readback_color(rb, x, y, z);
   todo_wine_if(todo) ok_(file, line)(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
}

static inline BOOL check_readback_pixel_4bpp_rgba(const void *got, const void *expected, uint32_t max_diff)
{
    const uint32_t *a = got;
    const uint32_t *b = expected;

    return compare_color_4bpp(*a, *b, max_diff);
}

typedef BOOL (*check_readback_pixel_func)(const void *, const void *, uint32_t);
static inline check_readback_pixel_func get_readback_pixel_func_for_d3dformat(D3DFORMAT format)
{
    switch (format)
    {
        case D3DFMT_A8B8G8R8:
        case D3DFMT_A8R8G8B8:
            return check_readback_pixel_4bpp_rgba;

        default:
            assert(0 && "Need to add format to get_readback_pixel_func_for_d3dformat().");
            return 0;
    }
}

#define check_test_readback(got, got_row_pitch, got_slice_pitch, expected, width, height, depth, format, max_diff) \
    _check_test_readback(__FILE__, __LINE__, got, got_row_pitch, got_slice_pitch, expected, width, height, depth, \
            format, max_diff)
static inline void _check_test_readback(const char *file, uint32_t line, const void *got, int32_t got_row_pitch,
        int32_t got_slice_pitch, const void *expected, uint32_t width, uint32_t height, uint32_t depth,
        D3DFORMAT format, uint32_t max_diff)
{
    check_readback_pixel_func check_readback_pixel = get_readback_pixel_func_for_d3dformat(format);
    unsigned int x, y, z, mismatch_count, expected_row_pitch, expected_slice_pitch;
    const unsigned int fmt_bpp = get_bpp_for_d3dformat(format);

    expected_row_pitch = fmt_bpp * width;
    expected_slice_pitch = expected_row_pitch * height;
    mismatch_count = 0;
    for (z = 0; z < depth; ++z)
    {
        const uint8_t *expected_slice = ((const uint8_t *)expected) + z * expected_slice_pitch;
        const uint8_t *got_slice = ((const uint8_t *)got) + z * got_slice_pitch;

        for (y = 0; y < height; ++y)
        {
            const uint8_t *expected_row = expected_slice + y * expected_row_pitch;
            const uint8_t *got_row = got_slice + y * got_row_pitch;

            for (x = 0; x < width; ++x)
            {
                const uint8_t *expected_ptr = expected_row + x * fmt_bpp;
                const uint8_t *got_ptr = got_row + x * fmt_bpp;

                if (!check_readback_pixel(got_ptr, expected_ptr, max_diff))
                    mismatch_count++;
            }
        }
    }
    ok_(file, line)(!mismatch_count, "Unexpected number of mismatched pixels %u.\n", mismatch_count);
}

static inline IDirect3DDevice9 *create_device(HWND *window)
{
    D3DPRESENT_PARAMETERS present_parameters = { 0 };
    IDirect3DDevice9 *device;
    IDirect3D9 *d3d;
    HRESULT hr;
    HWND wnd;

    *window = NULL;

    if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
            640, 480, NULL, NULL, NULL, NULL)))
    {
        skip("Couldn't create application window.\n");
        return NULL;
    }

    if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
    {
        skip("Couldn't create IDirect3D9 object.\n");
        DestroyWindow(wnd);
        return NULL;
    }

    present_parameters.Windowed = TRUE;
    present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
    hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_HARDWARE_VERTEXPROCESSING,
            &present_parameters, &device);
    IDirect3D9_Release(d3d);
    if (FAILED(hr))
    {
        skip("Failed to create IDirect3DDevice9 object %#lx.\n", hr);
        DestroyWindow(wnd);
        return NULL;
    }

    *window = wnd;
    return device;
}
